erow commited on
Commit
637ac87
·
1 Parent(s): a70375d
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -103,7 +103,7 @@ def process_ocr_task(image, model_size, ref_text, task_type):
103
 
104
  # Create a copy of the original image to draw on
105
  image_with_bboxes = image.copy()
106
- draw = ImageDraw.Draw(image_with_bboxes)
107
  w, h = image.size # Get original image dimensions
108
 
109
  for match in matches:
@@ -117,9 +117,9 @@ def process_ocr_task(image, model_size, ref_text, task_type):
117
  x2 = int(x2_norm / 1000 * w)
118
  y2 = int(y2_norm / 1000 * h)
119
 
120
- # Draw the rectangle with a red outline, 3 pixels wide
121
- draw.rectangle([x1, y1, x2, y2], outline="red", width=3)
122
-
123
  result_image_pil = image_with_bboxes
124
  else:
125
  # If no coordinates are found in the text, fall back to finding a pre-generated image
 
103
 
104
  # Create a copy of the original image to draw on
105
  image_with_bboxes = image.copy()
106
+ # draw = ImageDraw.Draw(image_with_bboxes)
107
  w, h = image.size # Get original image dimensions
108
 
109
  for match in matches:
 
117
  x2 = int(x2_norm / 1000 * w)
118
  y2 = int(y2_norm / 1000 * h)
119
 
120
+ # Crop the image to the bounding box
121
+ image_with_bboxes = image_with_bboxes.crop([x1, y1, x2, y2])
122
+
123
  result_image_pil = image_with_bboxes
124
  else:
125
  # If no coordinates are found in the text, fall back to finding a pre-generated image