Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,16 +37,21 @@ def recognize_handwritten_text(image):
|
|
37 |
return Image.fromarray(processed_image), "No text detected"
|
38 |
|
39 |
boxes = outputs[0]["boxes"]
|
|
|
40 |
pil_image = Image.fromarray(processed_image)
|
41 |
texts = []
|
42 |
|
43 |
# Adjust box unpacking based on actual structure
|
44 |
for box in boxes:
|
45 |
-
if len(box)
|
46 |
-
x_min, y_min,
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
else:
|
51 |
continue # Skip invalid boxes
|
52 |
|
|
|
37 |
return Image.fromarray(processed_image), "No text detected"
|
38 |
|
39 |
boxes = outputs[0]["boxes"]
|
40 |
+
print(f"Debug: Boxes structure = {boxes}") # Debug output to logs
|
41 |
pil_image = Image.fromarray(processed_image)
|
42 |
texts = []
|
43 |
|
44 |
# Adjust box unpacking based on actual structure
|
45 |
for box in boxes:
|
46 |
+
if len(box) == 4: # [x, y, width, height] format
|
47 |
+
x_min, y_min, width, height = box
|
48 |
+
x_max = x_min + width
|
49 |
+
y_max = y_min + height
|
50 |
+
elif len(box) == 2 and len(box[0]) == 2: # [[x, y], [width, height]] format
|
51 |
+
x_min, y_min = box[0]
|
52 |
+
width, height = box[1]
|
53 |
+
x_max = x_min + width
|
54 |
+
y_max = y_min + height
|
55 |
else:
|
56 |
continue # Skip invalid boxes
|
57 |
|