jdinh commited on
Commit
d56eef0
·
1 Parent(s): cc1ba20

Attempt to important fastai learner

Browse files
app.py.3ec09d1ad4059228116e1fb9e618c954.tmp ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['learn','classify_image','categories','image','label','examples','intf']
2
+
3
+ from huggingface_hub import hf_hub_download
4
+ from fastai.learner import *
5
+ import gradio as gr
6
+
7
+ learn = load_learner('model.pkl')
8
+
9
+ categories = ('airbaby','airchair','airflare','headspin','hollow back')
10
+
11
+ def classify_image(img):
12
+ pred, idx, probs = learn.predict(img)
13
+ return dict(zip(categories, map(float,probs)))
14
+
15
+ image = gr.inputs.Image(shape=(192,192))
16
+ label = gr.outputs.Label()
17
+ examples = ['air_chair.jpg','hollowback.jpeg','airbaby.jpeg','airflare.jpeg','headspin.jpeg']
18
+
19
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
20
+ intf.launch(inline=False)