File size: 10,997 Bytes
90b4364
 
 
 
89047b5
3648b1e
90b4364
528f68e
f240626
522af51
3903f4f
ebc32f0
90b4364
 
 
 
 
 
 
 
 
4818b14
90b4364
 
89047b5
90b4364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522af51
 
 
 
 
 
 
 
7e6465f
522af51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ebc32f0
 
 
 
 
4818b14
ebc32f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528f68e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3648b1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f240626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89047b5
 
 
 
 
 
 
 
302fc24
89047b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f240626
3903f4f
 
 
 
4818b14
3903f4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90b4364
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import os

import gradio as gr

from censor import _CENSOR_MODELS, _DEFAULT_CENSOR_MODEL, _gr_detect_censors
from eye import _EYE_MODELS, _DEFAULT_EYE_MODEL, _gr_detect_eyes
from face import _FACE_MODELS, _DEFAULT_FACE_MODEL, _gr_detect_faces
from halfbody import _HALFBODY_MODELS, _DEFAULT_HALFBODY_MODEL, _gr_detect_halfbodies
from hand import _gr_detect_hands, _HAND_MODELS, _DEFAULT_HAND_MODEL
from head import _gr_detect_heads, _HEAD_MODELS, _DEFAULT_HEAD_MODEL
from manbits import _MANBIT_MODELS, _DEFAULT_MANBIT_MODEL, _gr_detect_manbits
from person import _PERSON_MODELS, _DEFAULT_PERSON_MODEL, _gr_detect_person

if __name__ == '__main__':
    with gr.Blocks() as demo:
        with gr.Tabs():
            with gr.Tab('Face Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_face_input_image = gr.Image(type='pil', label='Original Image')
                        gr_face_model = gr.Dropdown(_FACE_MODELS, value=_DEFAULT_FACE_MODEL, label='Model')
                        gr_face_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_face_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
                            gr_face_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')

                        gr_face_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_face_output_image = gr.Image(type='pil', label="Labeled")

                    gr_face_submit.click(
                        _gr_detect_faces,
                        inputs=[
                            gr_face_input_image, gr_face_model,
                            gr_face_infer_size, gr_face_score_threshold, gr_face_iou_threshold,
                        ],
                        outputs=[gr_face_output_image],
                    )

            with gr.Tab('Head Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_head_input_image = gr.Image(type='pil', label='Original Image')
                        gr_head_model = gr.Dropdown(_HEAD_MODELS, value=_DEFAULT_HEAD_MODEL, label='Model')
                        gr_head_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_head_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
                            gr_head_score_threshold = gr.Slider(0.0, 1.0, 0.3, label='Score Threshold')

                        gr_head_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_head_output_image = gr.Image(type='pil', label="Labeled")

                    gr_head_submit.click(
                        _gr_detect_heads,
                        inputs=[
                            gr_head_input_image, gr_head_model,
                            gr_head_infer_size, gr_head_score_threshold, gr_head_iou_threshold,
                        ],
                        outputs=[gr_head_output_image],
                    )

            with gr.Tab('Person Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_person_input_image = gr.Image(type='pil', label='Original Image')
                        gr_person_model = gr.Dropdown(_PERSON_MODELS, value=_DEFAULT_PERSON_MODEL, label='Model')
                        gr_person_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_person_iou_threshold = gr.Slider(0.0, 1.0, 0.5, label='IOU Threshold')
                            gr_person_score_threshold = gr.Slider(0.0, 1.0, 0.3, label='Score Threshold')

                        gr_person_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_person_output_image = gr.Image(type='pil', label="Labeled")

                    gr_person_submit.click(
                        _gr_detect_person,
                        inputs=[
                            gr_person_input_image, gr_person_model,
                            gr_person_infer_size, gr_person_score_threshold, gr_person_iou_threshold,
                        ],
                        outputs=[gr_person_output_image],
                    )

            with gr.Tab('Half Body Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_halfbody_input_image = gr.Image(type='pil', label='Original Image')
                        gr_halfbody_model = gr.Dropdown(_HALFBODY_MODELS, value=_DEFAULT_HALFBODY_MODEL, label='Model')
                        gr_halfbody_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_halfbody_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
                            gr_halfbody_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')

                        gr_halfbody_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_halfbody_output_image = gr.Image(type='pil', label="Labeled")

                    gr_halfbody_submit.click(
                        _gr_detect_halfbodies,
                        inputs=[
                            gr_halfbody_input_image, gr_halfbody_model,
                            gr_halfbody_infer_size, gr_halfbody_score_threshold, gr_halfbody_iou_threshold,
                        ],
                        outputs=[gr_halfbody_output_image],
                    )

            with gr.Tab('Eyes Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_eye_input_image = gr.Image(type='pil', label='Original Image')
                        gr_eye_model = gr.Dropdown(_EYE_MODELS, value=_DEFAULT_EYE_MODEL, label='Model')
                        gr_eye_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_eye_iou_threshold = gr.Slider(0.0, 1.0, 0.3, label='IOU Threshold')
                            gr_eye_score_threshold = gr.Slider(0.0, 1.0, 0.3, label='Score Threshold')

                        gr_eye_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_eye_output_image = gr.Image(type='pil', label="Labeled")

                    gr_eye_submit.click(
                        _gr_detect_eyes,
                        inputs=[
                            gr_eye_input_image, gr_eye_model,
                            gr_eye_infer_size, gr_eye_score_threshold, gr_eye_iou_threshold,
                        ],
                        outputs=[gr_eye_output_image],
                    )

            with gr.Tab('Hand Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_hand_input_image = gr.Image(type='pil', label='Original Image')
                        gr_hand_model = gr.Dropdown(_HAND_MODELS, value=_DEFAULT_HAND_MODEL, label='Model')
                        gr_hand_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_hand_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
                            gr_hand_score_threshold = gr.Slider(0.0, 1.0, 0.35, label='Score Threshold')

                        gr_hand_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_hand_output_image = gr.Image(type='pil', label="Labeled")

                    gr_hand_submit.click(
                        _gr_detect_hands,
                        inputs=[
                            gr_hand_input_image, gr_hand_model,
                            gr_hand_infer_size, gr_hand_score_threshold, gr_hand_iou_threshold,
                        ],
                        outputs=[gr_hand_output_image],
                    )

            with gr.Tab('Censor Point Detection'):
                with gr.Row():
                    with gr.Column():
                        gr_censor_input_image = gr.Image(type='pil', label='Original Image')
                        gr_censor_model = gr.Dropdown(_CENSOR_MODELS, value=_DEFAULT_CENSOR_MODEL, label='Model')
                        gr_censor_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_censor_iou_threshold = gr.Slider(0.0, 1.0, 0.5, label='IOU Threshold')
                            gr_censor_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')

                        gr_censor_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_censor_output_image = gr.Image(type='pil', label="Labeled")

                    gr_censor_submit.click(
                        _gr_detect_censors,
                        inputs=[
                            gr_censor_input_image, gr_censor_model,
                            gr_censor_infer_size, gr_censor_score_threshold, gr_censor_iou_threshold,
                        ],
                        outputs=[gr_censor_output_image],
                    )

            with gr.Tab('Manbits Detection\n(Deprecated)'):
                with gr.Row():
                    with gr.Column():
                        gr_manbit_input_image = gr.Image(type='pil', label='Original Image')
                        gr_manbit_model = gr.Dropdown(_MANBIT_MODELS, value=_DEFAULT_MANBIT_MODEL, label='Model')
                        gr_manbit_infer_size = gr.Slider(480, 960, value=640, step=32, label='Max Infer Size')
                        with gr.Row():
                            gr_manbit_iou_threshold = gr.Slider(0.0, 1.0, 0.7, label='IOU Threshold')
                            gr_manbit_score_threshold = gr.Slider(0.0, 1.0, 0.25, label='Score Threshold')

                        gr_manbit_submit = gr.Button(value='Submit', variant='primary')

                    with gr.Column():
                        gr_manbit_output_image = gr.Image(type='pil', label="Labeled")

                    gr_manbit_submit.click(
                        _gr_detect_manbits,
                        inputs=[
                            gr_manbit_input_image, gr_manbit_model,
                            gr_manbit_infer_size, gr_manbit_score_threshold, gr_manbit_iou_threshold,
                        ],
                        outputs=[gr_manbit_output_image],
                    )

    demo.queue(os.cpu_count()).launch()