Spaces:
Runtime error
Runtime error
add paddle ocr
Browse filesFiles changed (5)
76 unmodified lines7778798081828333 unmodified lines11711811912012176 unmodified linesimage_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})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)33 unmodified lines)# demo.launch(debug=False, show_error=True, share=True)demo.launch(share=True, server_port=7861, server_name='0.0.0.0')# demo.queue().launch(share=False)76 unmodified lines7778798081828333 unmodified lines11711811912012176 unmodified linesimage_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}, use_paddleocr=True)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)33 unmodified lines)# demo.launch(debug=False, show_error=True, share=True)# demo.launch(share=True, server_port=7861, server_name='0.0.0.0')demo.queue().launch(share=False)
13 unmodified lines14151613 unmodified linesacceleratetimmeinops==0.8.013 unmodified lines141516171813 unmodified linesacceleratetimmeinops==0.8.0paddlepaddlepaddleocr
17 unmodified lines18192021222324345 unmodified lines37037137237337437537637737837938038138238313 unmodified lines39739839940040140240317 unmodified lines# %matplotlib inlinefrom matplotlib import pyplot as pltimport easyocrreader = easyocr.Reader(['en'])import timeimport base64345 unmodified linesdef check_ocr_box(image_path, display_img = True, output_bb_format='xywh', goal_filtering=None, easyocr_args=None):if easyocr_args is None:easyocr_args = {}result = reader.readtext(image_path, **easyocr_args)is_goal_filtered = False# print('goal filtering pred:', result[-5:])coord = [item[0] for item in result]text = [item[1] for item in result]# read the image using cv2if display_img:opencv_img = cv2.imread(image_path)13 unmodified lineselif output_bb_format == 'xyxy':bb = [get_xyxy(item) for item in coord]# print('bounding box!!!', bb)return (text, bb), is_goal_filtered17 unmodified lines1819202122232425262728293031323334345 unmodified lines38038138238338438538638738838939039139239339439539639713 unmodified lines41141241341441541641717 unmodified lines# %matplotlib inlinefrom matplotlib import pyplot as pltimport easyocrfrom paddleocr import PaddleOCRreader = easyocr.Reader(['en'])paddle_ocr = PaddleOCR(lang='en', # other lang also availableuse_angle_cls=False,use_gpu=False, # using cuda will conflict with pytorch in the same processshow_log=False,max_batch_size=1024,use_dilation=True, # improves accuracydet_db_score_mode='slow', # improves accuracyrec_batch_num=1024)import timeimport base64345 unmodified linesdef check_ocr_box(image_path, display_img = True, output_bb_format='xywh', goal_filtering=None, easyocr_args=None, use_paddleocr=False):if use_paddleocr:result = paddle_ocr.ocr(image_path, cls=False)[0]coord = [item[0] for item in result]text = [item[1][0] for item in result]else: # EasyOCRif easyocr_args is None:easyocr_args = {}result = reader.readtext(image_path, **easyocr_args)# print('goal filtering pred:', result[-5:])coord = [item[0] for item in result]text = [item[1] for item in result]# read the image using cv2if display_img:opencv_img = cv2.imread(image_path)13 unmodified lineselif output_bb_format == 'xyxy':bb = [get_xyxy(item) for item in coord]# print('bounding box!!!', bb)return (text, bb), goal_filtering
__pycache__/utils.cpython-312.pyc
app.py+3-3
imgs/saved_image_demo.png


requirements.txt+2
utils.py+23-9