Spaces:
Running
Running
Add NMS and fix conversion
Browse files
app.py
CHANGED
@@ -79,11 +79,13 @@ class KeypointDetector:
|
|
79 |
target_sizes=torch.tensor([(image.height, image.width)]),
|
80 |
threshold=0.3
|
81 |
)
|
|
|
|
|
82 |
|
83 |
# Get boxes and scores for human class (index 0 in COCO dataset)
|
84 |
-
boxes =
|
85 |
-
scores =
|
86 |
-
return boxes
|
87 |
|
88 |
def detect_keypoints(self, image: Image.Image):
|
89 |
"""Detect keypoints in the image"""
|
@@ -106,7 +108,7 @@ class KeypointDetector:
|
|
106 |
|
107 |
# Setup detections for bounding boxes
|
108 |
detections = sv.Detections(
|
109 |
-
xyxy=
|
110 |
confidence=scores,
|
111 |
class_id=np.array([0]*len(scores))
|
112 |
)
|
|
|
79 |
target_sizes=torch.tensor([(image.height, image.width)]),
|
80 |
threshold=0.3
|
81 |
)
|
82 |
+
|
83 |
+
dets = sv.Detections.from_transformers(results[0]).with_nms(0.5)
|
84 |
|
85 |
# Get boxes and scores for human class (index 0 in COCO dataset)
|
86 |
+
boxes = dets.xyxy[dets.class_id == 0]
|
87 |
+
scores = dets.confidence[dets.class_id == 0]
|
88 |
+
return boxes, scores
|
89 |
|
90 |
def detect_keypoints(self, image: Image.Image):
|
91 |
"""Detect keypoints in the image"""
|
|
|
108 |
|
109 |
# Setup detections for bounding boxes
|
110 |
detections = sv.Detections(
|
111 |
+
xyxy=boxes,
|
112 |
confidence=scores,
|
113 |
class_id=np.array([0]*len(scores))
|
114 |
)
|