Spaces:
Running
on
Zero
Running
on
Zero
first
Browse files- detection.py +3 -3
detection.py
CHANGED
|
@@ -600,7 +600,7 @@ def run_inference(
|
|
| 600 |
print(f" - {label_name}: {count}件")
|
| 601 |
|
| 602 |
# NMS(Non-Maximum Suppression)で重複検出をマージ
|
| 603 |
-
# クラスごとにNMS
|
| 604 |
from torchvision.ops import nms
|
| 605 |
|
| 606 |
# ZeroGPU対応: モデルからデバイスを動的に取得
|
|
@@ -629,8 +629,8 @@ def run_inference(
|
|
| 629 |
boxes_tensor = torch.tensor([[x1, y1, x2, y2] for x1, y1, x2, y2, _ in boxes_scores], device=device)
|
| 630 |
scores_tensor = torch.tensor([score for _, _, _, _, score in boxes_scores], device=device)
|
| 631 |
|
| 632 |
-
# NMS適用(IoU閾値: 0.
|
| 633 |
-
keep_indices = nms(boxes_tensor, scores_tensor, iou_threshold=0.
|
| 634 |
|
| 635 |
# マージ後の検出を追加
|
| 636 |
for idx in keep_indices.cpu().numpy():
|
|
|
|
| 600 |
print(f" - {label_name}: {count}件")
|
| 601 |
|
| 602 |
# NMS(Non-Maximum Suppression)で重複検出をマージ
|
| 603 |
+
# クラスごとにNMSを適用(異なるクラス間の重複は許可)
|
| 604 |
from torchvision.ops import nms
|
| 605 |
|
| 606 |
# ZeroGPU対応: モデルからデバイスを動的に取得
|
|
|
|
| 629 |
boxes_tensor = torch.tensor([[x1, y1, x2, y2] for x1, y1, x2, y2, _ in boxes_scores], device=device)
|
| 630 |
scores_tensor = torch.tensor([score for _, _, _, _, score in boxes_scores], device=device)
|
| 631 |
|
| 632 |
+
# NMS適用(IoU閾値: 0.4 - より厳しく重複を削除)
|
| 633 |
+
keep_indices = nms(boxes_tensor, scores_tensor, iou_threshold=0.4)
|
| 634 |
|
| 635 |
# マージ後の検出を追加
|
| 636 |
for idx in keep_indices.cpu().numpy():
|