Spaces:
Sleeping
Sleeping
jeremyarancio
commited on
Commit
β’
cebced8
1
Parent(s):
1e31676
Init
Browse files- app.py +5 -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 |
-
|
28 |
-
|
|
|
|
|
|
|
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