Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
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 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|