fix error
Browse files
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 |
-
#
|
| 121 |
-
|
| 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
|