Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Version 1.0. Copyright Colleen Mahr 2025
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
from fastai.vision.all import *
|
5 |
+
import skimage
|
6 |
+
|
7 |
+
learn = load_learner('export.pkl')
|
8 |
+
|
9 |
+
labels = learn.dls.vocab
|
10 |
+
def predict(img):
|
11 |
+
img = PILImage.create(img)
|
12 |
+
pred,pred_idx,probs = learn.predict(img)
|
13 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
14 |
+
|
15 |
+
title = "Science Fair Cornea Ulcer Image Classifier"
|
16 |
+
description = "Version 1.0. Copyright Colleen Mahr 2025"
|
17 |
+
#article = "<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
18 |
+
examples = ['testitraceimage.jpeg']
|
19 |
+
interpretation = 'default'
|
20 |
+
enable_queue = True
|
21 |
+
|
22 |
+
demo = gr.Interface(
|
23 |
+
fn=predict,
|
24 |
+
inputs=gr.Image(height = 512, width = 512),
|
25 |
+
outputs=gr.Label(num_top_classes=2),
|
26 |
+
title=title,
|
27 |
+
description=description,
|
28 |
+
#article=article,
|
29 |
+
#examples=examples,
|
30 |
+
#interpretation='default',
|
31 |
+
#enable_queue=enable_queue
|
32 |
+
)
|
33 |
+
|
34 |
+
demo.launch()
|