Update app.py
Browse files
app.py
CHANGED
|
@@ -22,8 +22,11 @@ def predict(image):
|
|
| 22 |
# Convert PIL Image to NumPy array (required by Ultralytics)
|
| 23 |
image = np.array(image)
|
| 24 |
results = model(image)
|
| 25 |
-
detections = []
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
for *xyxy, conf, cls in results.xyxy[0]:
|
| 28 |
x1, y1, x2, y2 = map(int, xyxy)
|
| 29 |
label = labels[int(cls)]
|
|
|
|
| 22 |
# Convert PIL Image to NumPy array (required by Ultralytics)
|
| 23 |
image = np.array(image)
|
| 24 |
results = model(image)
|
|
|
|
| 25 |
|
| 26 |
+
if len(results.xyxy[0]) == 0:
|
| 27 |
+
return "No components detected."
|
| 28 |
+
|
| 29 |
+
detections = []
|
| 30 |
for *xyxy, conf, cls in results.xyxy[0]:
|
| 31 |
x1, y1, x2, y2 = map(int, xyxy)
|
| 32 |
label = labels[int(cls)]
|