Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -43,9 +43,9 @@ def predict(pilimg,Threshold):
|
|
43 |
if type(Threshold) is None:
|
44 |
Threshold=0.38
|
45 |
|
46 |
-
return predict2(image_np),predict3(image_np),Threshold
|
47 |
|
48 |
-
def predict2(image_np):
|
49 |
|
50 |
results = detection_model(image_np)
|
51 |
|
@@ -63,7 +63,7 @@ def predict2(image_np):
|
|
63 |
category_index,
|
64 |
use_normalized_coordinates=True,
|
65 |
max_boxes_to_draw=20,
|
66 |
-
min_score_thresh=0.38,
|
67 |
agnostic_mode=False,
|
68 |
line_thickness=2)
|
69 |
|
@@ -72,7 +72,7 @@ def predict2(image_np):
|
|
72 |
return result_pil_img2
|
73 |
|
74 |
|
75 |
-
def predict3(image_np):
|
76 |
|
77 |
results = detection_model2(image_np)
|
78 |
|
@@ -90,7 +90,7 @@ def predict3(image_np):
|
|
90 |
category_index,
|
91 |
use_normalized_coordinates=True,
|
92 |
max_boxes_to_draw=20,
|
93 |
-
min_score_thresh
|
94 |
agnostic_mode=False,
|
95 |
line_thickness=2)
|
96 |
|
@@ -172,13 +172,13 @@ test12 = os.path.join(os.path.dirname(__file__), "data/test12.jpeg")
|
|
172 |
base_image = gr.Interface(
|
173 |
fn=predict,
|
174 |
# inputs=[gr.Image(type="pil"),gr.Slider(minimum=0.01, maximum=1, value=0.38 ,label="Threshold",info="[not in used]to set prediction confidence threshold")],
|
175 |
-
inputs=[gr.Image(type="pil"),gr.Textbox(value=0.38 ,label="To change default 0.38 Threshold",info="to
|
176 |
|
177 |
outputs=[gr.Image(type="pil",label="Base Model Inference"),gr.Image(type="pil",label="Tuned Model Inference"),gr.Textbox(label="Tuned Model Inference")],
|
178 |
title="Luffy and Chopper Head detection. SSD mobile net V2 320x320",
|
179 |
description="Upload a Image for prediction or click on below examples. Prediction confident >38% will be shown in dectected images. Threshold slider is WIP",
|
180 |
examples=
|
181 |
-
[[test1
|
182 |
cache_examples=True,examples_per_page=12#,label="select image with 0.38 threshold to inference, you may amend threshold after inference"
|
183 |
)
|
184 |
|
|
|
43 |
if type(Threshold) is None:
|
44 |
Threshold=0.38
|
45 |
|
46 |
+
return predict2(image_np,Threshold),predict3(image_np,Threshold),Threshold
|
47 |
|
48 |
+
def predict2(image_np,Threshold):
|
49 |
|
50 |
results = detection_model(image_np)
|
51 |
|
|
|
63 |
category_index,
|
64 |
use_normalized_coordinates=True,
|
65 |
max_boxes_to_draw=20,
|
66 |
+
min_score_thresh=Threshold,#0.38,
|
67 |
agnostic_mode=False,
|
68 |
line_thickness=2)
|
69 |
|
|
|
72 |
return result_pil_img2
|
73 |
|
74 |
|
75 |
+
def predict3(image_np,Threshold):
|
76 |
|
77 |
results = detection_model2(image_np)
|
78 |
|
|
|
90 |
category_index,
|
91 |
use_normalized_coordinates=True,
|
92 |
max_boxes_to_draw=20,
|
93 |
+
min_score_thresh=Threshold,#.38,
|
94 |
agnostic_mode=False,
|
95 |
line_thickness=2)
|
96 |
|
|
|
172 |
base_image = gr.Interface(
|
173 |
fn=predict,
|
174 |
# inputs=[gr.Image(type="pil"),gr.Slider(minimum=0.01, maximum=1, value=0.38 ,label="Threshold",info="[not in used]to set prediction confidence threshold")],
|
175 |
+
inputs=[gr.Image(type="pil"),gr.Textbox(value=0.38 ,label="To change default 0.38 prediction confidence Threshold",info="Select image with 0.38 threshold to start, you may amend threshold after each first image inference")],
|
176 |
|
177 |
outputs=[gr.Image(type="pil",label="Base Model Inference"),gr.Image(type="pil",label="Tuned Model Inference"),gr.Textbox(label="Tuned Model Inference")],
|
178 |
title="Luffy and Chopper Head detection. SSD mobile net V2 320x320",
|
179 |
description="Upload a Image for prediction or click on below examples. Prediction confident >38% will be shown in dectected images. Threshold slider is WIP",
|
180 |
examples=
|
181 |
+
[[test1],[test2],[test3],[test4],[test5],[test6],[test7],[test8],[test9],[test10],[test11],[test12],],
|
182 |
cache_examples=True,examples_per_page=12#,label="select image with 0.38 threshold to inference, you may amend threshold after inference"
|
183 |
)
|
184 |
|