Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,27 +16,31 @@ class_map = checkpoint_and_model["class_map"]
|
|
16 |
img_size = checkpoint_and_model["img_size"]
|
17 |
valid_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(img_size), tfms.A.Normalize()])
|
18 |
|
19 |
-
examples
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def show_preds(input_image):
|
22 |
img = PIL.Image.fromarray(input_image, "RGB")
|
23 |
-
pred_dict
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
30 |
|
31 |
gr_interface = gr.Interface(
|
32 |
fn=show_preds,
|
33 |
inputs=["image"],
|
34 |
-
outputs=[gr.outputs.Image(type="pil", label="
|
35 |
-
title="
|
36 |
-
description="
|
37 |
-
article="<p style='text-align: center'><a href='https://dicksonneoh.com/portfolio/how_to_deploy_od_models_on_android_with_flutter/' target='_blank'>Blog post</a></p>",
|
38 |
examples=examples,
|
39 |
-
theme="dark-grass",
|
40 |
-
enable_queue=True
|
41 |
)
|
42 |
-
gr_interface.launch()
|
|
|
16 |
img_size = checkpoint_and_model["img_size"]
|
17 |
valid_tfms = tfms.A.Adapter([*tfms.A.resize_and_pad(img_size), tfms.A.Normalize()])
|
18 |
|
19 |
+
# Populate examples in Gradio interface
|
20 |
+
examples = [
|
21 |
+
['./1.jpg'],
|
22 |
+
['./2.jpg'],
|
23 |
+
['./3.jpg']
|
24 |
+
]
|
25 |
|
26 |
def show_preds(input_image):
|
27 |
img = PIL.Image.fromarray(input_image, "RGB")
|
28 |
+
pred_dict = model_type.end2end_detect(img, valid_tfms, model,
|
29 |
+
class_map=class_map,
|
30 |
+
detection_threshold=0.5,
|
31 |
+
display_label=True,
|
32 |
+
display_bbox=True,
|
33 |
+
return_img=True,
|
34 |
+
font_size=35,
|
35 |
+
label_color="#FF59D6")
|
36 |
+
return pred_dict["img"]
|
37 |
|
38 |
gr_interface = gr.Interface(
|
39 |
fn=show_preds,
|
40 |
inputs=["image"],
|
41 |
+
outputs=[gr.outputs.Image(type="pil", label="VFNet Inference")],
|
42 |
+
title="Fridge Object Detector",
|
43 |
+
description="A VFNet model that detects common objects found in fridge. Upload an image or click an example image below to use.",
|
|
|
44 |
examples=examples,
|
|
|
|
|
45 |
)
|
46 |
+
gr_interface.launch(inline=False, share=False, debug=True)
|