Spaces:
Running
Running
narugo1992
commited on
Commit
•
4818b14
1
Parent(s):
99411de
dev(narugo): update sizes
Browse files- app.py +3 -3
- face.py +3 -3
- manbits.py +3 -3
- person.py +3 -3
- yolo_.py +1 -1
app.py
CHANGED
@@ -14,7 +14,7 @@ if __name__ == '__main__':
|
|
14 |
with gr.Column():
|
15 |
gr_face_input_image = gr.Image(type='pil', label='Original Image')
|
16 |
gr_face_model = gr.Dropdown(_FACE_MODELS, value=_DEFAULT_FACE_MODEL, label='Model')
|
17 |
-
gr_face_infer_size = gr.Slider(480,
|
18 |
with gr.Row():
|
19 |
gr_face_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
|
20 |
gr_face_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')
|
@@ -38,7 +38,7 @@ if __name__ == '__main__':
|
|
38 |
with gr.Column():
|
39 |
gr_person_input_image = gr.Image(type='pil', label='Original Image')
|
40 |
gr_person_model = gr.Dropdown(_PERSON_MODELS, value=_DEFAULT_PERSON_MODEL, label='Model')
|
41 |
-
gr_person_infer_size = gr.Slider(480,
|
42 |
with gr.Row():
|
43 |
gr_person_iou_threshold = gr.Slider(0.0, 1.0, 0.5, label='IOU Threshold')
|
44 |
gr_person_score_threshold = gr.Slider(0.0, 1.0, 0.3, label='Score Threshold')
|
@@ -62,7 +62,7 @@ if __name__ == '__main__':
|
|
62 |
with gr.Column():
|
63 |
gr_manbit_input_image = gr.Image(type='pil', label='Original Image')
|
64 |
gr_manbit_model = gr.Dropdown(_MANBIT_MODELS, value=_DEFAULT_MANBIT_MODEL, label='Model')
|
65 |
-
gr_manbit_infer_size = gr.Slider(480,
|
66 |
with gr.Row():
|
67 |
gr_manbit_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
|
68 |
gr_manbit_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')
|
|
|
14 |
with gr.Column():
|
15 |
gr_face_input_image = gr.Image(type='pil', label='Original Image')
|
16 |
gr_face_model = gr.Dropdown(_FACE_MODELS, value=_DEFAULT_FACE_MODEL, label='Model')
|
17 |
+
gr_face_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
|
18 |
with gr.Row():
|
19 |
gr_face_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
|
20 |
gr_face_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')
|
|
|
38 |
with gr.Column():
|
39 |
gr_person_input_image = gr.Image(type='pil', label='Original Image')
|
40 |
gr_person_model = gr.Dropdown(_PERSON_MODELS, value=_DEFAULT_PERSON_MODEL, label='Model')
|
41 |
+
gr_person_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
|
42 |
with gr.Row():
|
43 |
gr_person_iou_threshold = gr.Slider(0.0, 1.0, 0.5, label='IOU Threshold')
|
44 |
gr_person_score_threshold = gr.Slider(0.0, 1.0, 0.3, label='Score Threshold')
|
|
|
62 |
with gr.Column():
|
63 |
gr_manbit_input_image = gr.Image(type='pil', label='Original Image')
|
64 |
gr_manbit_model = gr.Dropdown(_MANBIT_MODELS, value=_DEFAULT_MANBIT_MODEL, label='Model')
|
65 |
+
gr_manbit_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
|
66 |
with gr.Row():
|
67 |
gr_manbit_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
|
68 |
gr_manbit_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')
|
face.py
CHANGED
@@ -26,18 +26,18 @@ def _open_face_detect_model(model_name):
|
|
26 |
_LABELS = ['head']
|
27 |
|
28 |
|
29 |
-
def detect_faces(image: ImageTyping,
|
30 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7) \
|
31 |
-> List[Tuple[Tuple[int, int, int, int], str, float]]:
|
32 |
image = load_image(image, mode='RGB')
|
33 |
new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
|
34 |
|
35 |
data = rgb_encode(new_image)[None, ...]
|
36 |
-
output, = _open_face_detect_model(
|
37 |
return _data_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size, _LABELS)
|
38 |
|
39 |
|
40 |
-
def _gr_detect_faces(image: ImageTyping, model_name: str, max_infer_size=
|
41 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7):
|
42 |
ret = detect_faces(image, model_name, max_infer_size, conf_threshold, iou_threshold)
|
43 |
return detection_visualize(image, ret, _LABELS)
|
|
|
26 |
_LABELS = ['head']
|
27 |
|
28 |
|
29 |
+
def detect_faces(image: ImageTyping, model_name: str, max_infer_size=640,
|
30 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7) \
|
31 |
-> List[Tuple[Tuple[int, int, int, int], str, float]]:
|
32 |
image = load_image(image, mode='RGB')
|
33 |
new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
|
34 |
|
35 |
data = rgb_encode(new_image)[None, ...]
|
36 |
+
output, = _open_face_detect_model(model_name).run(['output0'], {'images': data})
|
37 |
return _data_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size, _LABELS)
|
38 |
|
39 |
|
40 |
+
def _gr_detect_faces(image: ImageTyping, model_name: str, max_infer_size=640,
|
41 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7):
|
42 |
ret = detect_faces(image, model_name, max_infer_size, conf_threshold, iou_threshold)
|
43 |
return detection_visualize(image, ret, _LABELS)
|
manbits.py
CHANGED
@@ -28,18 +28,18 @@ _LABELS = [
|
|
28 |
]
|
29 |
|
30 |
|
31 |
-
def detect_manbits(image: ImageTyping,
|
32 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7) \
|
33 |
-> List[Tuple[Tuple[int, int, int, int], str, float]]:
|
34 |
image = load_image(image, mode='RGB')
|
35 |
new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
|
36 |
|
37 |
data = rgb_encode(new_image)[None, ...]
|
38 |
-
output, = _open_manbits_detect_model(
|
39 |
return _data_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size, _LABELS)
|
40 |
|
41 |
|
42 |
-
def _gr_detect_manbits(image: ImageTyping, model_name: str, max_infer_size=
|
43 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7):
|
44 |
ret = detect_manbits(image, model_name, max_infer_size, conf_threshold, iou_threshold)
|
45 |
return detection_visualize(image, ret, _LABELS)
|
|
|
28 |
]
|
29 |
|
30 |
|
31 |
+
def detect_manbits(image: ImageTyping, model_name: str, max_infer_size=640,
|
32 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7) \
|
33 |
-> List[Tuple[Tuple[int, int, int, int], str, float]]:
|
34 |
image = load_image(image, mode='RGB')
|
35 |
new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
|
36 |
|
37 |
data = rgb_encode(new_image)[None, ...]
|
38 |
+
output, = _open_manbits_detect_model(model_name).run(['output0'], {'images': data})
|
39 |
return _data_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size, _LABELS)
|
40 |
|
41 |
|
42 |
+
def _gr_detect_manbits(image: ImageTyping, model_name: str, max_infer_size=640,
|
43 |
conf_threshold: float = 0.25, iou_threshold: float = 0.7):
|
44 |
ret = detect_manbits(image, model_name, max_infer_size, conf_threshold, iou_threshold)
|
45 |
return detection_visualize(image, ret, _LABELS)
|
person.py
CHANGED
@@ -27,17 +27,17 @@ def _open_person_detect_model(model_name):
|
|
27 |
_LABELS = ['person']
|
28 |
|
29 |
|
30 |
-
def detect_person(image: ImageTyping,
|
31 |
conf_threshold: float = 0.3, iou_threshold: float = 0.5):
|
32 |
image = load_image(image, mode='RGB')
|
33 |
new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
|
34 |
|
35 |
data = rgb_encode(new_image)[None, ...]
|
36 |
-
output, = _open_person_detect_model(
|
37 |
return _data_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size, _LABELS)
|
38 |
|
39 |
|
40 |
-
def _gr_detect_person(image: ImageTyping, model_name: str, max_infer_size=
|
41 |
conf_threshold: float = 0.3, iou_threshold: float = 0.5):
|
42 |
ret = detect_person(image, model_name, max_infer_size, conf_threshold, iou_threshold)
|
43 |
return detection_visualize(image, ret, _LABELS)
|
|
|
27 |
_LABELS = ['person']
|
28 |
|
29 |
|
30 |
+
def detect_person(image: ImageTyping, model_name: str, max_infer_size=640,
|
31 |
conf_threshold: float = 0.3, iou_threshold: float = 0.5):
|
32 |
image = load_image(image, mode='RGB')
|
33 |
new_image, old_size, new_size = _image_preprocess(image, max_infer_size)
|
34 |
|
35 |
data = rgb_encode(new_image)[None, ...]
|
36 |
+
output, = _open_person_detect_model(model_name).run(['output0'], {'images': data})
|
37 |
return _data_postprocess(output[0], conf_threshold, iou_threshold, old_size, new_size, _LABELS)
|
38 |
|
39 |
|
40 |
+
def _gr_detect_person(image: ImageTyping, model_name: str, max_infer_size=640,
|
41 |
conf_threshold: float = 0.3, iou_threshold: float = 0.5):
|
42 |
ret = detect_person(image, model_name, max_infer_size, conf_threshold, iou_threshold)
|
43 |
return detection_visualize(image, ret, _LABELS)
|
yolo_.py
CHANGED
@@ -65,7 +65,7 @@ def _yolo_nms(boxes, scores, thresh: float = 0.7) -> List[int]:
|
|
65 |
return keep
|
66 |
|
67 |
|
68 |
-
def _image_preprocess(image: Image.Image, max_infer_size: int =
|
69 |
old_width, old_height = image.width, image.height
|
70 |
new_width, new_height = old_width, old_height
|
71 |
r = max_infer_size / max(new_width, new_height)
|
|
|
65 |
return keep
|
66 |
|
67 |
|
68 |
+
def _image_preprocess(image: Image.Image, max_infer_size: int = 640, align: int = 32):
|
69 |
old_width, old_height = image.width, image.height
|
70 |
new_width, new_height = old_width, old_height
|
71 |
r = max_infer_size / max(new_width, new_height)
|