Update app.py
Browse files
app.py
CHANGED
|
@@ -19,14 +19,14 @@ def process_image(image):
|
|
| 19 |
# Extract annotated image and labels with class names
|
| 20 |
annotated_image = result.plot()
|
| 21 |
|
| 22 |
-
#
|
| 23 |
detected_areas_labels = "\n".join([
|
| 24 |
f"{class_names[int(box.cls.item())].upper()}: {box.conf:.2f}" for box in result.boxes
|
| 25 |
])
|
| 26 |
|
| 27 |
return annotated_image, detected_areas_labels
|
| 28 |
except Exception as e:
|
| 29 |
-
return None, f"Error processing image: {e}
|
| 30 |
|
| 31 |
|
| 32 |
# Create the Gradio Interface
|
|
|
|
| 19 |
# Extract annotated image and labels with class names
|
| 20 |
annotated_image = result.plot()
|
| 21 |
|
| 22 |
+
# Use cls attribute for labels and get class name from model, DO NOT use .item() on box.conf
|
| 23 |
detected_areas_labels = "\n".join([
|
| 24 |
f"{class_names[int(box.cls.item())].upper()}: {box.conf:.2f}" for box in result.boxes
|
| 25 |
])
|
| 26 |
|
| 27 |
return annotated_image, detected_areas_labels
|
| 28 |
except Exception as e:
|
| 29 |
+
return None, f"Error processing image: {e}
|
| 30 |
|
| 31 |
|
| 32 |
# Create the Gradio Interface
|