Spaces:
Build error
Build error
Commit
·
dfa7438
1
Parent(s):
31607dc
added sample images
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ inceptionV3_model = InceptionV3Classifier()
|
|
| 18 |
mobilenet_model = MobileNetClassifier()
|
| 19 |
|
| 20 |
def make_prediction(image, model_type):
|
| 21 |
-
if "CNN (
|
| 22 |
top_classes, top_probs = custom_model.classify_image(image, top_k=3)
|
| 23 |
return {CLASS_NAMES[cls_id]:str(prob) for cls_id, prob in zip(top_classes, top_probs)}
|
| 24 |
elif "ResNet50" == model_type:
|
|
@@ -61,7 +61,7 @@ def train_model(epochs, batch_size, validation_split):
|
|
| 61 |
|
| 62 |
|
| 63 |
def update_train_param_display(model_type):
|
| 64 |
-
if "CNN (
|
| 65 |
return [gr.update(visible=True), gr.update(visible=False)]
|
| 66 |
return [gr.update(visible=False), gr.update(visible=True)]
|
| 67 |
|
|
@@ -75,7 +75,7 @@ if __name__ == "__main__":
|
|
| 75 |
with gr.Column(scale=1):
|
| 76 |
img_input = gr.Image()
|
| 77 |
model_type = gr.Dropdown(
|
| 78 |
-
["CNN (
|
| 79 |
"ResNet50",
|
| 80 |
"VGG16",
|
| 81 |
"Inception v3",
|
|
@@ -101,6 +101,18 @@ if __name__ == "__main__":
|
|
| 101 |
|
| 102 |
with gr.Column(scale=1):
|
| 103 |
output_label = gr.Label()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
# app logic
|
| 106 |
predict_btn_1.click(make_prediction, inputs=[img_input, model_type], outputs=[output_label])
|
|
|
|
| 18 |
mobilenet_model = MobileNetClassifier()
|
| 19 |
|
| 20 |
def make_prediction(image, model_type):
|
| 21 |
+
if "CNN (Custom)" == model_type:
|
| 22 |
top_classes, top_probs = custom_model.classify_image(image, top_k=3)
|
| 23 |
return {CLASS_NAMES[cls_id]:str(prob) for cls_id, prob in zip(top_classes, top_probs)}
|
| 24 |
elif "ResNet50" == model_type:
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
def update_train_param_display(model_type):
|
| 64 |
+
if "CNN (Custom)" == model_type:
|
| 65 |
return [gr.update(visible=True), gr.update(visible=False)]
|
| 66 |
return [gr.update(visible=False), gr.update(visible=True)]
|
| 67 |
|
|
|
|
| 75 |
with gr.Column(scale=1):
|
| 76 |
img_input = gr.Image()
|
| 77 |
model_type = gr.Dropdown(
|
| 78 |
+
["CNN (Custom)",
|
| 79 |
"ResNet50",
|
| 80 |
"VGG16",
|
| 81 |
"Inception v3",
|
|
|
|
| 101 |
|
| 102 |
with gr.Column(scale=1):
|
| 103 |
output_label = gr.Label()
|
| 104 |
+
|
| 105 |
+
gr.Markdown("## Sample Images")
|
| 106 |
+
gr.Examples(
|
| 107 |
+
examples=[os.path.join(os.path.dirname(__file__), "assets/dog_2.jpg"),
|
| 108 |
+
os.path.join(os.path.dirname(__file__), "assets/truck.jpg"),
|
| 109 |
+
os.path.join(os.path.dirname(__file__), "assets/car.jpg")
|
| 110 |
+
],
|
| 111 |
+
inputs=img_input,
|
| 112 |
+
outputs=[segmentation_img_output, depth_img_output, dist_img_output, pcd_img_output],
|
| 113 |
+
fn=process_image,
|
| 114 |
+
cache_examples=True,
|
| 115 |
+
)
|
| 116 |
|
| 117 |
# app logic
|
| 118 |
predict_btn_1.click(make_prediction, inputs=[img_input, model_type], outputs=[output_label])
|