soamikapadia commited on
Commit
52dfc8c
·
1 Parent(s): 392c23f

update model, app.py

Browse files
Files changed (2) hide show
  1. app.py +18 -3
  2. model.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,22 @@
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
  import gradio as gr
2
+ from fastai.vision.all import *
3
 
4
+ def is_cat(x): return x[0].is_upper()
 
5
 
6
+ categories = ('Dog', 'Cat')
7
+
8
+ def classify_image(image):
9
+ pred, idx, probs = learn.predict(image)
10
+ return dict(zip(categories, map(float, probs)))
11
+
12
+ learn = load_learner('model.pkl')
13
+
14
+
15
+ def predict(image: str):
16
+ im = PILImage.create(image)
17
+ return classify_image(im)
18
+
19
+ image = gr.Image(height=192, type='filepath')
20
+ label = gr.Label()
21
+ iface = gr.Interface(fn=predict, inputs=image, outputs=label)
22
  iface.launch()
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24a787ea73df7a4f7e0df712f3a541391312d6ddfddf3c09f51b39c532bb780c
3
+ size 47064766