jeremyarancio commited on
Commit
cebced8
β€’
1 Parent(s): 1e31676
Files changed (2) hide show
  1. app.py +5 -2
  2. images/000_067_500_6567_1.jpg +0 -0
app.py CHANGED
@@ -24,8 +24,11 @@ def detect_and_crop(image: Image.Image) -> Image.Image:
24
  results = MODEL.predict(image,**INF_PARAMETERS)
25
  result = results[0]
26
  for box in result.boxes.xyxy.cpu().numpy():
27
- cropped_image = image.crop(box=box)
28
- return cropped_image
 
 
 
29
 
30
 
31
  # Gradio UI
 
24
  results = MODEL.predict(image,**INF_PARAMETERS)
25
  result = results[0]
26
  for box in result.boxes.xyxy.cpu().numpy():
27
+ if len(box) > 0:
28
+ cropped_image = image.crop(box=box)
29
+ return cropped_image
30
+ else:
31
+ return image
32
 
33
 
34
  # Gradio UI
images/000_067_500_6567_1.jpg ADDED