Spaces:
Running
Running
File size: 4,231 Bytes
90b4364 3903f4f ebc32f0 90b4364 ebc32f0 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 |
import os
import gradio as gr
from face import _FACE_MODELS, _DEFAULT_FACE_MODEL, _gr_detect_faces
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, 1600, value=1216, 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('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, 1600, value=1216, 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('Manbits Detection'):
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, 1600, value=1216, 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()
|