amkj84 commited on
Commit
59322b3
·
verified ·
1 Parent(s): d207917

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
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)]