akstrov commited on
Commit
0ea01b6
1 Parent(s): a32ec6f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -24
app.py CHANGED
@@ -1,29 +1,16 @@
1
- import gradio as gr
2
- import os
3
- import subprocess
4
-
5
- subprocess.call(["pip", "install", "fastai"])
6
-
7
  from fastai.vision.all import *
 
8
 
 
9
 
10
- def image_mod(image):
11
- learn_inf = load_learner("model.pkl")
12
- return learn_inf.predict(image)[0]
13
-
14
 
15
- demo = gr.Interface(
16
- image_mod,
17
- gr.Image(type="pil"),
18
- "image",
19
- flagging_options=["blurry", "incorrect", "other"],
20
- examples=[
21
- os.path.join(os.path.dirname(__file__), "images/cheetah1.jpg"),
22
- os.path.join(os.path.dirname(__file__), "images/lion.jpg"),
23
- os.path.join(os.path.dirname(__file__), "images/logo.png"),
24
- os.path.join(os.path.dirname(__file__), "images/tower.jpg"),
25
- ],
26
- )
27
 
28
- if __name__ == "__main__":
29
- demo.launch()
 
 
 
 
 
 
 
1
  from fastai.vision.all import *
2
+ import gradio as gr
3
 
4
+ learn = load_learner('model.pkl')
5
 
6
+ breeds = tuple(learn.dls.vocab)
7
+ def classify_image(image):
8
+ pred,idx,probs = learn.predict(image)
9
+ return dict(zip(breeds,map(float,probs)))
10
 
11
+ image = gr.inputs.Image(shape=(192,192))
12
+ label = gr.outputs.Label()
13
+ exemples = ['chihuahua.jpg','german_shepard.jpg']
 
 
 
 
 
 
 
 
 
14
 
15
+ intf = gr.Interface(fn = classify_image,inputs=image,outputs=label,exemples=exemples)
16
+ intf.launch(inline=False)