Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def predict_image(image_path, model):
|
| 2 |
if model == "InceptionV3":
|
| 3 |
img_size = (550, 475)
|
|
@@ -43,4 +58,32 @@ def predict_image(image_path, model):
|
|
| 43 |
return "Add another image, confidence is below 50%"
|
| 44 |
|
| 45 |
predicted_label = labels[predicted_class]
|
| 46 |
-
return predicted_label
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import cv2
|
| 3 |
+
import onnxruntime
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
onnx_model_vgg19_path = "./vgg19-30epochs.onnx"
|
| 7 |
+
onnx_model_inceptionv3_path = "./InceptionV3-20epochs.onnx"
|
| 8 |
+
onnx_model_resnet101_path = "./Resnet101-30epochs.onnx"
|
| 9 |
+
onnx_model_vgg16_path = "./vgg16-20epochs.onnx"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
labels = ['Ajloun Castle', 'Hadrians Arch', 'Petra-siq', 'Roman Ruins-Jerash', 'Roman amphitheater', 'The Cardo Maximus of Jerash', 'Wadi Rum', 'petra-Treasury', 'umm qais']
|
| 14 |
+
|
| 15 |
+
|
| 16 |
def predict_image(image_path, model):
|
| 17 |
if model == "InceptionV3":
|
| 18 |
img_size = (550, 475)
|
|
|
|
| 58 |
return "Add another image, confidence is below 50%"
|
| 59 |
|
| 60 |
predicted_label = labels[predicted_class]
|
| 61 |
+
return predicted_label
|
| 62 |
+
|
| 63 |
+
inputs_image = [
|
| 64 |
+
gr.Image(type="filepath", label="Input Image"),
|
| 65 |
+
gr.Radio(choices=[
|
| 66 |
+
"InceptionV3",
|
| 67 |
+
"Vgg19",
|
| 68 |
+
"Vgg16",
|
| 69 |
+
"Resnet101",
|
| 70 |
+
], type="value", label="Select_model")
|
| 71 |
+
]
|
| 72 |
+
outputs_text = [gr.Textbox(label="Site")]
|
| 73 |
+
interface_image = gr.Interface(
|
| 74 |
+
inputs=inputs_image,
|
| 75 |
+
fn=predict_image,
|
| 76 |
+
outputs=outputs_text,
|
| 77 |
+
title="classifier_demo"
|
| 78 |
+
# examples=[["Wadi Rum.jpg", "Wadi Rum","Vgg19" ],
|
| 79 |
+
# ["Ajloun Castle.jpg", "Ajloun Castle","Vgg19"],
|
| 80 |
+
# ["Hadrians Arch.jpg", "Hadrians Arch","Vgg19" ],
|
| 81 |
+
# ["Patra_Siq.jpg", "Patra_Siq","Vgg19"],
|
| 82 |
+
# ["petra-Treasury.jpg", "Petra-Treasury","Vgg19" ],
|
| 83 |
+
# ["Roman amphitheater.jpg", "Vgg19","Roman amphitheater","Vgg19"],
|
| 84 |
+
# ["Roman Ruins-Jerash.jpg", "Roman Ruins-Jerash","Vgg19"],
|
| 85 |
+
# ["The Cardo Maximus of Jerash.jpg", "The Cardo Maximus of Jerash","Vgg19"],
|
| 86 |
+
# ["umm qais.jpg", "umm qais","Vgg19"]]
|
| 87 |
+
|
| 88 |
+
)
|
| 89 |
+
interface_image.launch()
|