Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -33,34 +33,43 @@ for root, dirs, files in os.walk(r"sample_images/"):
|
|
33 |
# Populate examples in Gradio interface
|
34 |
example_images = [["sample_images/" + file] for file in files]
|
35 |
# Columns: Input Image | Label | Box | Detection Threshold
|
36 |
-
examples = [
|
37 |
-
[example_images[0], False, True, 0.5],
|
38 |
-
[example_images[1], True, True, 0.5],
|
39 |
-
[example_images[2], False, True, 0.7],
|
40 |
-
[example_images[3], True, True, 0.7],
|
41 |
-
[example_images[4], False, True, 0.5],
|
42 |
-
[example_images[5], False, True, 0.5],
|
43 |
-
[example_images[6], False, True, 0.6],
|
44 |
-
[example_images[7], False, True, 0.6],
|
45 |
-
]
|
|
|
|
|
46 |
|
47 |
|
48 |
-
def show_preds(input_image, display_label, display_bbox, detection_threshold):
|
49 |
-
|
50 |
-
|
|
|
51 |
img = PIL.Image.fromarray(input_image, "RGB")
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
return pred_dict["img"], len(pred_dict["detection"]["bboxes"])
|
65 |
|
66 |
|
@@ -81,10 +90,10 @@ article = "<p style='text-align: center'><a href='https://dicksonneoh.com/' targ
|
|
81 |
gr_interface = gr.Interface(
|
82 |
fn=show_preds,
|
83 |
inputs=[
|
84 |
-
"image"
|
85 |
-
display_chkbox_label,
|
86 |
-
display_chkbox_box,
|
87 |
-
detection_threshold_slider,
|
88 |
],
|
89 |
outputs=outputs,
|
90 |
title="Microalgae Detector with RetinaNet",
|
|
|
33 |
# Populate examples in Gradio interface
|
34 |
example_images = [["sample_images/" + file] for file in files]
|
35 |
# Columns: Input Image | Label | Box | Detection Threshold
|
36 |
+
#examples = [
|
37 |
+
# [example_images[0], False, True, 0.5],
|
38 |
+
# [example_images[1], True, True, 0.5],
|
39 |
+
# [example_images[2], False, True, 0.7],
|
40 |
+
# [example_images[3], True, True, 0.7],
|
41 |
+
# [example_images[4], False, True, 0.5],
|
42 |
+
# [example_images[5], False, True, 0.5],
|
43 |
+
# [example_images[6], False, True, 0.6],
|
44 |
+
# [example_images[7], False, True, 0.6],
|
45 |
+
#]
|
46 |
+
|
47 |
+
examples = [[example_images[0], example_images[1], example_images[2], example_images[3]]]
|
48 |
|
49 |
|
50 |
+
#def show_preds(input_image, display_label, display_bbox, detection_threshold):
|
51 |
+
def show_preds(input_image):
|
52 |
+
# if detection_threshold == 0:
|
53 |
+
#detection_threshold = 0.5
|
54 |
img = PIL.Image.fromarray(input_image, "RGB")
|
55 |
+
|
56 |
+
pred_dict = model_type.end2end_detect(img, valid_tfms, model, class_map=class_map, detection_threshold=0.5,
|
57 |
+
display_label=True, display_bbox=True, return_img=True,
|
58 |
+
font_size=16, label_color="#FF59D6")
|
59 |
+
|
60 |
+
#pred_dict = model_type.end2end_detect(
|
61 |
+
# img,
|
62 |
+
# valid_tfms,
|
63 |
+
# model,
|
64 |
+
# class_map=class_map,
|
65 |
+
# detection_threshold=detection_threshold,
|
66 |
+
# display_label=display_label,
|
67 |
+
# display_bbox=display_bbox,
|
68 |
+
# return_img=True,
|
69 |
+
# font_size=16,
|
70 |
+
# label_color="#FF59D6",
|
71 |
+
#)
|
72 |
+
|
73 |
return pred_dict["img"], len(pred_dict["detection"]["bboxes"])
|
74 |
|
75 |
|
|
|
90 |
gr_interface = gr.Interface(
|
91 |
fn=show_preds,
|
92 |
inputs=[
|
93 |
+
"image"#,
|
94 |
+
#display_chkbox_label,
|
95 |
+
#display_chkbox_box,
|
96 |
+
#detection_threshold_slider,
|
97 |
],
|
98 |
outputs=outputs,
|
99 |
title="Microalgae Detector with RetinaNet",
|