Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import onnxruntime
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import os
|
| 4 |
+
from PIL import Image
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
model_path = 'multi_target_resnet50.pkl'
|
| 8 |
+
|
| 9 |
+
model = load_learner(model_path)
|
| 10 |
+
|
| 11 |
+
def result(path):
|
| 12 |
+
|
| 13 |
+
pred,_,probability = model.predict(path)
|
| 14 |
+
|
| 15 |
+
return pred
|
| 16 |
+
|
| 17 |
+
path = 'test images/'
|
| 18 |
+
|
| 19 |
+
image_path = []
|
| 20 |
+
|
| 21 |
+
for i in os.listdir(path):
|
| 22 |
+
image_path.append(path+i)
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
image = gr.inputs.Image(shape =(300,300))
|
| 26 |
+
label = gr.outputs.Label()
|
| 27 |
+
|
| 28 |
+
iface = gr.Interface(fn=result, inputs=image, outputs=label, examples = image_path)
|
| 29 |
+
iface.launch(inline = False)
|