flobbit commited on
Commit
eb2425f
·
1 Parent(s): 7e6a388

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -20
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
- # Cell
8
- #learn = load_learner('ohbugger2k.pkl')
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
- # Cell
24
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples,
25
- title="Oh! Bugger! 2k", description="Trained on 130133 images over 2000 species using ResNet18. Provide an image or select from one below.")
 
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()