Abdullah-Habib commited on
Commit
b2f6ebb
·
1 Parent(s): c6cd735

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __all__ = ['is_Rabbit',"learn",'classify_image', 'categories','image','label','examples','intf']
2
+
3
+ # Cell
4
+ from fastai.vision.all import *
5
+ import gradio as gr
6
+ def is_cat(x): return x[0].isupper()
7
+
8
+
9
+ learn = load_learner ('model.pkl')
10
+ # Cell
11
+ categories = ('Rabbit', 'Hare')
12
+ def classify_image (img) :
13
+ pred, idx, probs = learn.predict(img)
14
+ return dict(zip(categories, map(float,probs)))
15
+ # Cell
16
+ image = gr.inputs.Image(shape=(192, 192))
17
+ label = gr.outputs.Label ()
18
+ examples=['Rabbit.jpg', 'TestRabbit.jpg','Hare.jpg']
19
+ intf = gr.Interface(fn=classify_image,inputs=image, outputs=label, examples=examples)
20
+ intf.launch(inline=False)