Spaces:
Runtime error
Runtime error
Upload app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,12 @@
|
|
1 |
-
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
2 |
-
|
3 |
-
# Cell
|
4 |
from fastai.vision.all import *
|
5 |
import gradio as gr
|
6 |
|
7 |
-
#
|
8 |
-
#
|
9 |
-
learn = load_learner('flobbit/ohbugger2k')
|
10 |
-
|
11 |
-
# Cell
|
12 |
-
categories = learn.dls.vocab
|
13 |
-
|
14 |
-
def classify_image(img):
|
15 |
-
pred,idx,probs = learn.predict(img)
|
16 |
-
return dict(zip(categories, map(float,probs)))
|
17 |
-
|
18 |
-
# Cell
|
19 |
-
image = gr.inputs.Image(shape=(192, 192))
|
20 |
-
label = gr.outputs.Label(num_top_classes=5)
|
21 |
examples = ['carolina.jpg','abb.jpg','lady.jpg','mantis.jpg','monarch.jpg','western striped cucumber.jpg','carolina2.jpg', 'large milkweed bug.jpg', 'twice-stabbed.jpg', 'viceroy.jpg', 'lubber.jpg', 'GrashopperAulocaraElliotti958.webp']
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
intf.launch()
|
|
|
|
|
|
|
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
#image = gr.inputs.Image(shape=(192, 192))
|
5 |
+
#label = gr.outputs.Label(num_top_classes=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
examples = ['carolina.jpg','abb.jpg','lady.jpg','mantis.jpg','monarch.jpg','western striped cucumber.jpg','carolina2.jpg', 'large milkweed bug.jpg', 'twice-stabbed.jpg', 'viceroy.jpg', 'lubber.jpg', 'GrashopperAulocaraElliotti958.webp']
|
7 |
|
8 |
+
intf = gr.load(src='models',name='flobbit/ohbugger2k/',
|
9 |
+
examples=examples,
|
10 |
+
title="Oh! Bugger! 2k", description="Trained on 130133 images over 2000 species using ResNet18. Provide an image or select from one below."
|
11 |
+
)
|
12 |
intf.launch()
|