Commit
·
4756ba0
1
Parent(s):
683e77a
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ vgg16_model = VGG16Classifier()
|
|
| 18 |
inceptionV3_model = InceptionV3Classifier()
|
| 19 |
mobilenet_model = MobileNetClassifier()
|
| 20 |
|
| 21 |
-
def make_prediction(image, model_type):
|
| 22 |
if "CNN (Custom)" == model_type:
|
| 23 |
top_classes, top_probs = custom_model.classify_image(image, top_k=3)
|
| 24 |
return {CLASS_NAMES[cls_id]:str(prob) for cls_id, prob in zip(top_classes, top_probs)}
|
|
@@ -104,17 +104,18 @@ if __name__ == "__main__":
|
|
| 104 |
output_label = gr.Label()
|
| 105 |
|
| 106 |
gr.Markdown("## Sample Images")
|
| 107 |
-
print(os.path.join(os.path.dirname(__file__), "assets/dog_2.jpg"))
|
| 108 |
gr.Examples(
|
| 109 |
examples=[os.path.join(os.path.dirname(__file__), "assets/dog_2.jpg"),
|
| 110 |
os.path.join(os.path.dirname(__file__), "assets/truck.jpg"),
|
| 111 |
os.path.join(os.path.dirname(__file__), "assets/car.jpg")
|
| 112 |
],
|
| 113 |
-
inputs=
|
| 114 |
-
outputs=
|
| 115 |
fn=make_prediction,
|
| 116 |
cache_examples=True,
|
| 117 |
)
|
|
|
|
|
|
|
| 118 |
|
| 119 |
# app logic
|
| 120 |
predict_btn_1.click(make_prediction, inputs=[img_input, model_type], outputs=[output_label])
|
|
|
|
| 18 |
inceptionV3_model = InceptionV3Classifier()
|
| 19 |
mobilenet_model = MobileNetClassifier()
|
| 20 |
|
| 21 |
+
def make_prediction(image, model_type="CNN (Custom)"):
|
| 22 |
if "CNN (Custom)" == model_type:
|
| 23 |
top_classes, top_probs = custom_model.classify_image(image, top_k=3)
|
| 24 |
return {CLASS_NAMES[cls_id]:str(prob) for cls_id, prob in zip(top_classes, top_probs)}
|
|
|
|
| 104 |
output_label = gr.Label()
|
| 105 |
|
| 106 |
gr.Markdown("## Sample Images")
|
|
|
|
| 107 |
gr.Examples(
|
| 108 |
examples=[os.path.join(os.path.dirname(__file__), "assets/dog_2.jpg"),
|
| 109 |
os.path.join(os.path.dirname(__file__), "assets/truck.jpg"),
|
| 110 |
os.path.join(os.path.dirname(__file__), "assets/car.jpg")
|
| 111 |
],
|
| 112 |
+
inputs=img_input,
|
| 113 |
+
outputs=output_label,
|
| 114 |
fn=make_prediction,
|
| 115 |
cache_examples=True,
|
| 116 |
)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
|
| 120 |
# app logic
|
| 121 |
predict_btn_1.click(make_prediction, inputs=[img_input, model_type], outputs=[output_label])
|