acea2024 commited on
Commit
d16b937
·
1 Parent(s): 62fe721

excited add app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,7 +1,25 @@
 
 
 
 
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
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
+ import timm
7
+
8
+ # Cell
9
+ learn = load_learner('model.pkl')
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()
21
+ examples = ['2012 Honda Civic.jpg']
22
 
23
+ # Cell
24
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
25
+ intf.launch()