evalstate HF Staff commited on
Commit
98f260b
·
verified ·
1 Parent(s): e4a79c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -7,6 +7,9 @@ from PIL import Image
7
  import io
8
 
9
 
 
 
 
10
  import base64, os
11
  from util.utils import check_ocr_box, get_yolo_model, get_caption_model_processor, get_som_labeled_img
12
  import torch
@@ -51,6 +54,10 @@ def process(
51
  use_paddleocr,
52
  imgsz
53
  ) -> Optional[Image.Image]:
 
 
 
 
54
 
55
  # image_save_path = 'imgs/saved_image_demo.png'
56
  # image_input.save(image_save_path)
@@ -64,7 +71,7 @@ def process(
64
  }
65
  # import pdb; pdb.set_trace()
66
 
67
- ocr_bbox_rslt, is_goal_filtered = check_ocr_box(image_input, display_img = False, output_bb_format='xyxy', goal_filtering=None, easyocr_args={'paragraph': False, 'text_threshold':0.9}, use_paddleocr=use_paddleocr)
68
  text, ocr_bbox = ocr_bbox_rslt
69
  dino_labled_img, label_coordinates, parsed_content_list = get_som_labeled_img(image_input, 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, imgsz=imgsz,)
70
  image = Image.open(io.BytesIO(base64.b64decode(dino_labled_img)))
@@ -84,9 +91,9 @@ with gr.Blocks() as demo:
84
  label='Box Threshold', minimum=0.01, maximum=1.0, step=0.01, value=0.05)
85
  # set the threshold for removing the bounding boxes with large overlap, default is 0.1
86
  iou_threshold_component = gr.Slider(
87
- label='IOU Threshold', minimum=0.01, maximum=1.0, step=0.01, value=0.1)
88
- use_paddleocr_component = gr.Checkbox(
89
- label='Use PaddleOCR', value=True)
90
  imgsz_component = gr.Slider(
91
  label='Icon Detect Image Size', minimum=640, maximum=1920, step=32, value=640)
92
  submit_button_component = gr.Button(
 
7
  import io
8
 
9
 
10
+ # evalstate -- set remove paddle_ocr option, default to true.
11
+
12
+
13
  import base64, os
14
  from util.utils import check_ocr_box, get_yolo_model, get_caption_model_processor, get_som_labeled_img
15
  import torch
 
54
  use_paddleocr,
55
  imgsz
56
  ) -> Optional[Image.Image]:
57
+ """
58
+ Parse a GUI screen and return an array of structured elements, and a marked-up image showing the bounding boxes.
59
+ Array contains: Element Type (e.g. Icon, Text, Label), Bounding Box, Interactivity and Element Content
60
+ """
61
 
62
  # image_save_path = 'imgs/saved_image_demo.png'
63
  # image_input.save(image_save_path)
 
71
  }
72
  # import pdb; pdb.set_trace()
73
 
74
+ ocr_bbox_rslt, is_goal_filtered = check_ocr_box(image_input, display_img = False, output_bb_format='xyxy', goal_filtering=None, easyocr_args={'paragraph': False, 'text_threshold':0.9}, use_paddleocr=True)
75
  text, ocr_bbox = ocr_bbox_rslt
76
  dino_labled_img, label_coordinates, parsed_content_list = get_som_labeled_img(image_input, 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, imgsz=imgsz,)
77
  image = Image.open(io.BytesIO(base64.b64decode(dino_labled_img)))
 
91
  label='Box Threshold', minimum=0.01, maximum=1.0, step=0.01, value=0.05)
92
  # set the threshold for removing the bounding boxes with large overlap, default is 0.1
93
  iou_threshold_component = gr.Slider(
94
+ label='IOU (Intersection over Union) Threshold', minimum=0.01, maximum=1.0, step=0.01, value=0.1)
95
+ # use_paddleocr_component = gr.Checkbox(
96
+ # label='Use PaddleOCR', value=True)
97
  imgsz_component = gr.Slider(
98
  label='Icon Detect Image Size', minimum=640, maximum=1920, step=32, value=640)
99
  submit_button_component = gr.Button(