Update app.py
Browse files
app.py
CHANGED
|
@@ -70,7 +70,15 @@ def detect_document(image):
|
|
| 70 |
detected_classes = set()
|
| 71 |
labels = []
|
| 72 |
bounding_boxes = []
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
for result in results:
|
| 75 |
for box in result.boxes:
|
| 76 |
x1, y1, x2, y2 = map(int, box.xyxy[0])
|
|
|
|
| 70 |
detected_classes = set()
|
| 71 |
labels = []
|
| 72 |
bounding_boxes = []
|
| 73 |
+
|
| 74 |
+
if isinstance(image, np.ndarray):
|
| 75 |
+
if image.dtype != np.uint8:
|
| 76 |
+
image = (image * 255).clip(0, 255).astype(np.uint8) # Convert float to uint8
|
| 77 |
+
|
| 78 |
+
# Ensure correct shape (H, W, C)
|
| 79 |
+
if image.shape[0] == 1 and image.shape[1] == 1:
|
| 80 |
+
image = np.squeeze(image)
|
| 81 |
+
|
| 82 |
for result in results:
|
| 83 |
for box in result.boxes:
|
| 84 |
x1, y1, x2, y2 = map(int, box.xyxy[0])
|