Add paddleocr option

This commit is contained in:
Billy Cao
2024-10-29 10:56:34 +08:00
parent ba4e04fccb
commit be04aff52f
2 changed files with 29 additions and 11 deletions

View File

@@ -58,14 +58,15 @@ DEVICE = torch.device('cuda')
def process(
image_input,
box_threshold,
iou_threshold
iou_threshold,
use_paddleocr
) -> Optional[Image.Image]:
image_save_path = 'imgs/saved_image_demo.png'
image_input.save(image_save_path)
# import pdb; pdb.set_trace()
ocr_bbox_rslt, is_goal_filtered = check_ocr_box(image_save_path, display_img = False, output_bb_format='xyxy', goal_filtering=None, easyocr_args={'paragraph': False, 'text_threshold':0.9})
ocr_bbox_rslt, is_goal_filtered = check_ocr_box(image_save_path, display_img = False, output_bb_format='xyxy', goal_filtering=None, easyocr_args={'paragraph': False, 'text_threshold':0.9}, use_paddleocr=use_paddleocr)
text, ocr_bbox = ocr_bbox_rslt
# print('prompt:', prompt)
dino_labled_img, label_coordinates, parsed_content_list = get_som_labeled_img(image_save_path, yolo_model, BOX_TRESHOLD = box_threshold, output_coord_in_ratio=True, ocr_bbox=ocr_bbox,draw_bbox_config=draw_bbox_config, caption_model_processor=caption_model_processor, ocr_text=text,iou_threshold=iou_threshold)
@@ -88,6 +89,8 @@ with gr.Blocks() as demo:
# set the threshold for removing the bounding boxes with large overlap, default is 0.1
iou_threshold_component = gr.Slider(
label='IOU Threshold', minimum=0.01, maximum=1.0, step=0.01, value=0.1)
use_paddleocr_component = gr.Checkbox(
label='Use PaddleOCR', default=True)
submit_button_component = gr.Button(
value='Submit', variant='primary')
with gr.Column():
@@ -99,7 +102,8 @@ with gr.Blocks() as demo:
inputs=[
image_input_component,
box_threshold_component,
iou_threshold_component
iou_threshold_component,
use_paddleocr_component
],
outputs=[image_output_component, text_output_component]
)