Spaces:
Runtime error
Runtime error
valentynliubchenko
commited on
Commit
·
02e3ba7
1
Parent(s):
e2717de
fixed not detectd
Browse files
app.py
CHANGED
|
@@ -22,6 +22,9 @@ def process_image(input_image, model_name, conf):
|
|
| 22 |
im_array = r.plot()
|
| 23 |
im_array = im_array.astype(np.uint8)
|
| 24 |
|
|
|
|
|
|
|
|
|
|
| 25 |
for box in r.boxes:
|
| 26 |
class_name = r.names[box.cls[0].item()]
|
| 27 |
class_counts[class_name] = class_counts.get(class_name, 0) + 1
|
|
|
|
| 22 |
im_array = r.plot()
|
| 23 |
im_array = im_array.astype(np.uint8)
|
| 24 |
|
| 25 |
+
if len(r.boxes) == 0: # If no objects are detected
|
| 26 |
+
return None, "No objects detected."
|
| 27 |
+
|
| 28 |
for box in r.boxes:
|
| 29 |
class_name = r.names[box.cls[0].item()]
|
| 30 |
class_counts[class_name] = class_counts.get(class_name, 0) + 1
|