nimapourjafar commited on
Commit
14df844
1 Parent(s): 2a2dab4

made gradio interface

Browse files
Files changed (2) hide show
  1. app.py +17 -4
  2. model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,20 @@
 
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
+ from fastai.vision.all import *
2
  import gradio as gr
3
 
4
+ def is_cat(x): return x[0].isupper()
 
5
 
6
+ learn = load_learner("model.pkl")
7
+
8
+ categories = ("Cat", "Dog")
9
+
10
+ def classify_image(img):
11
+ pred,pred_idx,probs = learn.predict(img)
12
+ return dict(zip(categories, map(float, probs)))
13
+
14
+ image = gr.inputs.Image(shape=(224, 224))
15
+ label = gr.outputs.Label()
16
+
17
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, capture_session=True)
18
+
19
+ if __name__ == "__main__":
20
+ intf.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c09d8f778f89c9eb588eefd9a5ba094eb163cd3ea708a4ea567a83e924f149f
3
+ size 47059947