This commit is contained in:
Abdul Rehman 2026-04-18 15:26:06 -07:00 committed by GitHub
commit 99d297aa79
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -252,6 +252,10 @@ class KeypointDraw:
Y = [keypoints[idx1][0], keypoints[idx2][0]]
X = [keypoints[idx1][1], keypoints[idx2][1]]
if math.isnan(X[0]) or math.isnan(X[1]) or math.isnan(Y[0]) or math.isnan(Y[1]):
continue
mX, mY = (X[0] + X[1]) / 2, (Y[0] + Y[1]) / 2
length = math.sqrt((X[0] - X[1]) ** 2 + (Y[0] - Y[1]) ** 2)
@ -269,6 +273,8 @@ class KeypointDraw:
for i in range(18):
if scores is not None and scores[i] < threshold:
continue
if math.isnan(keypoints[i][0]) or math.isnan(keypoints[i][1]):
continue
x, y = int(keypoints[i][0]), int(keypoints[i][1])
if 0 <= x < W and 0 <= y < H:
self.draw.circle(canvas, (x, y), 4, self.colors[i % len(self.colors)], thickness=-1)
@ -278,6 +284,8 @@ class KeypointDraw:
for i in range(18, 24):
if scores is not None and scores[i] < threshold:
continue
if math.isnan(keypoints[i][0]) or math.isnan(keypoints[i][1]):
continue
x, y = int(keypoints[i][0]), int(keypoints[i][1])
if 0 <= x < W and 0 <= y < H:
self.draw.circle(canvas, (x, y), 4, self.colors[i % len(self.colors)], thickness=-1)
@ -291,6 +299,9 @@ class KeypointDraw:
if scores[idx1] < threshold or scores[idx2] < threshold:
continue
if math.isnan(keypoints[idx1][0]) or math.isnan(keypoints[idx1][1]) or math.isnan(keypoints[idx2][0]) or math.isnan(keypoints[idx2][1]):
continue
x1, y1 = int(keypoints[idx1][0]), int(keypoints[idx1][1])
x2, y2 = int(keypoints[idx2][0]), int(keypoints[idx2][1])
@ -305,6 +316,8 @@ class KeypointDraw:
for i in range(92, 113):
if scores is not None and scores[i] < threshold:
continue
if math.isnan(keypoints[i][0]) or math.isnan(keypoints[i][1]):
continue
x, y = int(keypoints[i][0]), int(keypoints[i][1])
if x > eps and y > eps and 0 <= x < W and 0 <= y < H:
self.draw.circle(canvas, (x, y), 4, (0, 0, 255), thickness=-1)
@ -318,6 +331,9 @@ class KeypointDraw:
if scores[idx1] < threshold or scores[idx2] < threshold:
continue
if math.isnan(keypoints[idx1][0]) or math.isnan(keypoints[idx1][1]) or math.isnan(keypoints[idx2][0]) or math.isnan(keypoints[idx2][1]):
continue
x1, y1 = int(keypoints[idx1][0]), int(keypoints[idx1][1])
x2, y2 = int(keypoints[idx2][0]), int(keypoints[idx2][1])
@ -332,6 +348,8 @@ class KeypointDraw:
for i in range(113, 134):
if scores is not None and i < len(scores) and scores[i] < threshold:
continue
if math.isnan(keypoints[i][0]) or math.isnan(keypoints[i][1]):
continue
x, y = int(keypoints[i][0]), int(keypoints[i][1])
if x > eps and y > eps and 0 <= x < W and 0 <= y < H:
self.draw.circle(canvas, (x, y), 4, (0, 0, 255), thickness=-1)
@ -342,6 +360,8 @@ class KeypointDraw:
for i in range(24, 92):
if scores is not None and scores[i] < threshold:
continue
if math.isnan(keypoints[i][0]) or math.isnan(keypoints[i][1]):
continue
x, y = int(keypoints[i][0]), int(keypoints[i][1])
if x > eps and y > eps and 0 <= x < W and 0 <= y < H:
self.draw.circle(canvas, (x, y), face_point_size, (255, 255, 255), thickness=-1)