Spaces:
Runtime error
Runtime error
neallseth
commited on
Commit
•
3c5f505
1
Parent(s):
801ca3a
upading gradio functionality
Browse files- app.py +13 -3
- microbe_model.pkl +3 -0
- paramecium.jpg +0 -0
app.py
CHANGED
@@ -1,7 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
im = PILImage.create('paramecium.jpg')
|
5 |
+
examples = ['paramecium.jpg']
|
6 |
+
learn = load_learner('microbe_model.pkl')
|
7 |
|
8 |
+
|
9 |
+
def classify_image(img):
|
10 |
+
category_name, _, probs = learn.predict(img)
|
11 |
+
categories = learn.dls.vocab
|
12 |
+
return {category: f"{prob:.4f}" for category, prob in zip(categories, probs.tolist())}
|
13 |
+
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=classify_image, inputs="image",
|
16 |
+
outputs="label", examples=examples)
|
17 |
iface.launch()
|
microbe_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7733686d3f9b90add32f552ab0dff8ac50cd3bbdcaa5543094e10c7db158504e
|
3 |
+
size 46990955
|
paramecium.jpg
ADDED