cetusian commited on
Commit
2489fc8
1 Parent(s): f25cd9a
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ from fastai.vision.all import *
4
+ import gradio as gr
5
+ import timm
6
+
7
+
8
+ learn = load_learner('resnet34-DDriver.pkl')
9
+
10
+
11
+ categories = learn.dls.vocab
12
+
13
+ def classify_image(img):
14
+ pred,idx,probs = learn.predict(img)
15
+ return dict(zip(categories, map(float,probs)))
16
+
17
+
18
+ image = gr.Image()
19
+ label = gr.Label()
20
+ examples = ['ddd1.jpg', 'ddd2.jpg', 'ddd3.jpg', 'ddd4.jpg']
21
+
22
+
23
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
24
+ intf.launch(inline=False)