Spaces:
Runtime error
Runtime error
MYTE
commited on
Commit
•
b51d483
1
Parent(s):
9ad4818
app update
Browse files
app.py
CHANGED
@@ -1,7 +1,34 @@
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import load_learner
|
2 |
import gradio as gr
|
3 |
+
import platform
|
4 |
|
|
|
|
|
5 |
|
6 |
+
if platform.system() == "Windows":
|
7 |
+
import pathlib
|
8 |
+
temp = pathlib.PosixPath
|
9 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
10 |
+
|
11 |
+
|
12 |
+
model = load_learner("pst_recognizer_v0.pkl")
|
13 |
+
pst_labels = tuple(model.dls.vocab)
|
14 |
+
|
15 |
+
|
16 |
+
def pst_recognizer(pst_image):
|
17 |
+
pred, idx, probs = model.predict(pst_image)
|
18 |
+
return dict(zip(pst_labels, map(float, probs)))
|
19 |
+
|
20 |
+
|
21 |
+
image = gr.inputs.Image(shape=(192, 192))
|
22 |
+
label = gr.outputs.Label()
|
23 |
+
|
24 |
+
examples = [
|
25 |
+
"architecture_photography.jpg",
|
26 |
+
"double_exposure_photography.jpg",
|
27 |
+
"food_photography.jpg",
|
28 |
+
"landscape_photography.jpg",
|
29 |
+
"portrait_photography.jpg",
|
30 |
+
"street_photography.jpg"
|
31 |
+
]
|
32 |
+
|
33 |
+
iface = gr.Interface(fn=pst_recognizer, inputs=image, outputs=label, examples=examples)
|
34 |
+
iface.launch(inline=False, share=True)
|