Spaces:
Runtime error
Runtime error
Fix Image Error
Browse files
app.py
CHANGED
|
@@ -29,6 +29,14 @@ def predict(image):
|
|
| 29 |
for box in predicted_boxes:
|
| 30 |
# Box coordinates are normalized, so multiply by image dimensions
|
| 31 |
x0, y0, x1, y1 = box
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
draw.rectangle([x0 * width, y0 * height, x1 * width, y1 * height], outline="red", width=3)
|
| 33 |
|
| 34 |
# Return the image with bounding boxes drawn
|
|
@@ -43,4 +51,3 @@ interface = gr.Interface(
|
|
| 43 |
|
| 44 |
# Launch the Gradio app
|
| 45 |
interface.launch()
|
| 46 |
-
|
|
|
|
| 29 |
for box in predicted_boxes:
|
| 30 |
# Box coordinates are normalized, so multiply by image dimensions
|
| 31 |
x0, y0, x1, y1 = box
|
| 32 |
+
|
| 33 |
+
# Ensure that y0 < y1 and x0 < x1
|
| 34 |
+
if x1 < x0:
|
| 35 |
+
x0, x1 = x1, x0
|
| 36 |
+
if y1 < y0:
|
| 37 |
+
y0, y1 = y1, y0
|
| 38 |
+
|
| 39 |
+
# Draw the rectangle
|
| 40 |
draw.rectangle([x0 * width, y0 * height, x1 * width, y1 * height], outline="red", width=3)
|
| 41 |
|
| 42 |
# Return the image with bounding boxes drawn
|
|
|
|
| 51 |
|
| 52 |
# Launch the Gradio app
|
| 53 |
interface.launch()
|
|
|