Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,12 +37,12 @@ def load_model(model_repo_id):
|
|
| 37 |
return detection_model
|
| 38 |
|
| 39 |
|
| 40 |
-
def predict(pilimg):
|
| 41 |
|
| 42 |
image_np = pil_image_as_numpy_array(pilimg)
|
| 43 |
-
return predict2(image_np),predict3(image_np)
|
| 44 |
|
| 45 |
-
def predict2(image_np):
|
| 46 |
|
| 47 |
results = detection_model(image_np)
|
| 48 |
|
|
@@ -60,7 +60,7 @@ def predict2(image_np):
|
|
| 60 |
category_index,
|
| 61 |
use_normalized_coordinates=True,
|
| 62 |
max_boxes_to_draw=20,
|
| 63 |
-
min_score_thresh=0.38,
|
| 64 |
agnostic_mode=False,
|
| 65 |
line_thickness=2)
|
| 66 |
|
|
@@ -69,7 +69,7 @@ def predict2(image_np):
|
|
| 69 |
return result_pil_img2
|
| 70 |
|
| 71 |
|
| 72 |
-
def predict3(image_np):
|
| 73 |
|
| 74 |
results = detection_model2(image_np)
|
| 75 |
|
|
@@ -87,7 +87,7 @@ def predict3(image_np):
|
|
| 87 |
category_index,
|
| 88 |
use_normalized_coordinates=True,
|
| 89 |
max_boxes_to_draw=20,
|
| 90 |
-
min_score_thresh
|
| 91 |
agnostic_mode=False,
|
| 92 |
line_thickness=2)
|
| 93 |
|
|
@@ -168,7 +168,7 @@ test12 = os.path.join(os.path.dirname(__file__), "data/test12.jpeg")
|
|
| 168 |
|
| 169 |
base_image = gr.Interface(
|
| 170 |
fn=predict,
|
| 171 |
-
inputs=[gr.Image(type="pil"),gr.Slider(minimum=0.01, maximum=0.99, value=0.6 ,label="Threshold
|
| 172 |
outputs=[gr.Image(type="pil",label="Base Model"),gr.Image(type="pil",label="Tuned Model")],
|
| 173 |
title="Luffy and Chopper Head detection. SSD mobile net V2 320x320",
|
| 174 |
description="Upload a Image for prediction or click on below examples. Prediction confident >38% will be shown in dectected images. Threshold slider is WIP",
|
|
|
|
| 37 |
return detection_model
|
| 38 |
|
| 39 |
|
| 40 |
+
def predict(pilimg,Threshold):
|
| 41 |
|
| 42 |
image_np = pil_image_as_numpy_array(pilimg)
|
| 43 |
+
return predict2(image_np,float(Threshold)),predict3(image_np,float(Threshold))
|
| 44 |
|
| 45 |
+
def predict2(image_np,Threshold):
|
| 46 |
|
| 47 |
results = detection_model(image_np)
|
| 48 |
|
|
|
|
| 60 |
category_index,
|
| 61 |
use_normalized_coordinates=True,
|
| 62 |
max_boxes_to_draw=20,
|
| 63 |
+
min_score_thresh=float(Threshold),#0.38,
|
| 64 |
agnostic_mode=False,
|
| 65 |
line_thickness=2)
|
| 66 |
|
|
|
|
| 69 |
return result_pil_img2
|
| 70 |
|
| 71 |
|
| 72 |
+
def predict3(image_np,Threshold):
|
| 73 |
|
| 74 |
results = detection_model2(image_np)
|
| 75 |
|
|
|
|
| 87 |
category_index,
|
| 88 |
use_normalized_coordinates=True,
|
| 89 |
max_boxes_to_draw=20,
|
| 90 |
+
min_score_thresh=float(Threshold),#.38,
|
| 91 |
agnostic_mode=False,
|
| 92 |
line_thickness=2)
|
| 93 |
|
|
|
|
| 168 |
|
| 169 |
base_image = gr.Interface(
|
| 170 |
fn=predict,
|
| 171 |
+
inputs=[gr.Image(type="pil"),gr.Slider(minimum=0.01, maximum=0.99, value=0.6 ,label="Threshold",info="[not in used]to set prediction confidence threshold")],
|
| 172 |
outputs=[gr.Image(type="pil",label="Base Model"),gr.Image(type="pil",label="Tuned Model")],
|
| 173 |
title="Luffy and Chopper Head detection. SSD mobile net V2 320x320",
|
| 174 |
description="Upload a Image for prediction or click on below examples. Prediction confident >38% will be shown in dectected images. Threshold slider is WIP",
|