ydshieh HF staff commited on
Commit
0c3ab1a
1 Parent(s): 6eb6e60

Update draw_bboxes.py

Browse files
Files changed (1) hide show
  1. draw_bboxes.py +6 -4
draw_bboxes.py CHANGED
@@ -13,9 +13,8 @@ def is_overlapping(rect1, rect2):
13
  return not (x2 < x3 or x1 > x4 or y2 < y3 or y1 > y4)
14
 
15
 
16
- def draw_entity_boxes_on_image(image, entities):
17
  """_summary_
18
-
19
  Args:
20
  image (_type_): image or image path
21
  collect_entity_location (_type_): _description_
@@ -112,6 +111,9 @@ def draw_entity_boxes_on_image(image, entities):
112
  previous_bboxes.append((text_bg_x1, text_bg_y1, text_bg_x2, text_bg_y2))
113
 
114
  pil_image = Image.fromarray(new_image[:, :, [2, 1, 0]])
115
- pil_image.save("new_snowman.jpg")
 
 
 
116
 
117
- return new_image
 
13
  return not (x2 < x3 or x1 > x4 or y2 < y3 or y1 > y4)
14
 
15
 
16
+ def draw_entity_boxes_on_image(image, entities, show=False, save_path=None):
17
  """_summary_
 
18
  Args:
19
  image (_type_): image or image path
20
  collect_entity_location (_type_): _description_
 
111
  previous_bboxes.append((text_bg_x1, text_bg_y1, text_bg_x2, text_bg_y2))
112
 
113
  pil_image = Image.fromarray(new_image[:, :, [2, 1, 0]])
114
+ if save_path:
115
+ pil_image.save(save_path)
116
+ if show:
117
+ pil_image.show()
118
 
119
+ return new_image