DawnC commited on
Commit
69649b6
1 Parent(s): 764138e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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.02)
335
- y1 = max(0, y1 - h * 0.02)
336
- x2 = min(image.width, x2 + w * 0.02)
337
- y2 = min(image.height, y2 + h * 0.02)
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