Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -331,10 +331,10 @@ def detect_multiple_dogs(image, conf_threshold=0.3, iou_threshold=0.3):
|
|
331 |
x1, y1, x2, y2 = box
|
332 |
w, h = x2 - x1, y2 - y1
|
333 |
# 擴大檢測框範圍以包含完整的狗
|
334 |
-
x1 = max(0, x1 - w * 0.
|
335 |
-
y1 = max(0, y1 - h * 0.
|
336 |
-
x2 = min(image.width, x2 + w * 0.
|
337 |
-
y2 = min(image.height, y2 + h * 0.
|
338 |
cropped_image = image.crop((x1, y1, x2, y2))
|
339 |
detected_objects.append((cropped_image, confidence, [x1, y1, x2, y2], is_dog))
|
340 |
|
|
|
331 |
x1, y1, x2, y2 = box
|
332 |
w, h = x2 - x1, y2 - y1
|
333 |
# 擴大檢測框範圍以包含完整的狗
|
334 |
+
x1 = max(0, x1 - w * 0.01)
|
335 |
+
y1 = max(0, y1 - h * 0.01)
|
336 |
+
x2 = min(image.width, x2 + w * 0.01)
|
337 |
+
y2 = min(image.height, y2 + h * 0.01)
|
338 |
cropped_image = image.crop((x1, y1, x2, y2))
|
339 |
detected_objects.append((cropped_image, confidence, [x1, y1, x2, y2], is_dog))
|
340 |
|