marufc36 commited on
Commit
4bdbe22
·
1 Parent(s): b4df192

add app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import load_learner
2
+ import gradio as gr
3
+
4
+
5
+ labels=(
6
+ 'Abyssinian cat',
7
+ 'Bengal cat',
8
+ 'Birman cat',
9
+ 'Bombay cat',
10
+ 'British Longhair cat',
11
+ 'Burmese cat',
12
+ 'Burmilla cat',
13
+ 'Cornish Rex cat',
14
+ 'Cymric cat',
15
+ 'Donskoy cat'
16
+ )
17
+ model=load_learner(f'CatClassifier-v0.pkl')
18
+ def recognize_image(image):
19
+ pred, idx, probs=model.predict(image)
20
+ print(pred)
21
+ return dict(zip(labels, map(float, probs)))
22
+ image = gr.Image(image_mode="RGB")
23
+ label=gr.Label()
24
+ example=['test_images/th(11).jpeg']
25
+ iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label)
26
+ iface.launch(inline=False, share=True)