MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / oks_iou

Function oks_iou

PATH/core/solvers/utils/nms.py:51–86  ·  view source on GitHub ↗

Calculate oks ious. Args: g: Ground truth keypoints. d: Detected keypoints. a_g: Area of the ground truth object. a_d: Area of the detected object. sigmas: standard deviation of keypoint labelling. vis_thr: threshold of the keypoint visibility.

(g, d, a_g, a_d, sigmas=None, vis_thr=None)

Source from the content-addressed store, hash-verified

49
50
51def oks_iou(g, d, a_g, a_d, sigmas=None, vis_thr=None):
52 """Calculate oks ious.
53
54 Args:
55 g: Ground truth keypoints.
56 d: Detected keypoints.
57 a_g: Area of the ground truth object.
58 a_d: Area of the detected object.
59 sigmas: standard deviation of keypoint labelling.
60 vis_thr: threshold of the keypoint visibility.
61
62 Returns:
63 list: The oks ious.
64 """
65 if sigmas is None:
66 sigmas = np.array([
67 .26, .25, .25, .35, .35, .79, .79, .72, .72, .62, .62, 1.07, 1.07,
68 .87, .87, .89, .89
69 ]) / 10.0
70 vars = (sigmas * 2)**2
71 xg = g[0::3]
72 yg = g[1::3]
73 vg = g[2::3]
74 ious = np.zeros(len(d), dtype=np.float32)
75 for n_d in range(0, len(d)):
76 xd = d[n_d, 0::3]
77 yd = d[n_d, 1::3]
78 vd = d[n_d, 2::3]
79 dx = xd - xg
80 dy = yd - yg
81 e = (dx**2 + dy**2) / vars / ((a_g + a_d[n_d]) / 2 + np.spacing(1)) / 2
82 if vis_thr is not None:
83 ind = list(vg > vis_thr) and list(vd > vis_thr)
84 e = e[ind]
85 ious[n_d] = np.sum(np.exp(-e)) / len(e) if len(e) != 0 else 0.0
86 return ious
87
88
89def oks_nms(kpts_db, thr, sigmas=None, vis_thr=None):

Callers 2

oks_nmsFunction · 0.85
soft_oks_nmsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected