deepghs/text_detection
6
1import os2 3import gradio as gr4from imgutils.detect import detection_visualize5 6from detect import _ALL_MODELS, _DEFAULT_MODEL, detect_text7 8 9def _gr_detect_text(image, model: str, threshold: float):10 return detection_visualize(image, detect_text(image, model, threshold))11 12 13if __name__ == '__main__':14 with gr.Blocks() as demo:15 with gr.Row():16 with gr.Column():17 gr_face_input_image = gr.Image(type='pil', label='Original Image')18 gr_face_model = gr.Dropdown(_ALL_MODELS, value=_DEFAULT_MODEL, label='Model')19 with gr.Row():20 gr_face_score_threshold = gr.Slider(0.0, 1.0, 0.05, label='Score Threshold')21 22 gr_face_submit = gr.Button(value='Submit', variant='primary')23 24 with gr.Column():25 gr_face_output_image = gr.Image(type='pil', label="Labeled")26 27 gr_face_submit.click(28 _gr_detect_text,29 inputs=[30 gr_face_input_image, gr_face_model, gr_face_score_threshold,31 ],32 outputs=[gr_face_output_image],33 )34 35 demo.queue(os.cpu_count()).launch()36 