ultralytics 8.0.239 Ultralytics Actions and hub-sdk adoption (#7431)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Burhan <62214284+Burhan-Q@users.noreply.github.com> Co-authored-by: Kayzwer <68285002+Kayzwer@users.noreply.github.com>
This commit is contained in:
parent
e795277391
commit
fe27db2f6e
139 changed files with 6870 additions and 5125 deletions
|
|
@ -26,7 +26,7 @@ class AIGym:
|
|||
self.angle = None
|
||||
self.count = None
|
||||
self.stage = None
|
||||
self.pose_type = 'pushup'
|
||||
self.pose_type = "pushup"
|
||||
self.kpts_to_check = None
|
||||
|
||||
# Visual Information
|
||||
|
|
@ -36,13 +36,15 @@ class AIGym:
|
|||
# Check if environment support imshow
|
||||
self.env_check = check_imshow(warn=True)
|
||||
|
||||
def set_args(self,
|
||||
kpts_to_check,
|
||||
line_thickness=2,
|
||||
view_img=False,
|
||||
pose_up_angle=145.0,
|
||||
pose_down_angle=90.0,
|
||||
pose_type='pullup'):
|
||||
def set_args(
|
||||
self,
|
||||
kpts_to_check,
|
||||
line_thickness=2,
|
||||
view_img=False,
|
||||
pose_up_angle=145.0,
|
||||
pose_down_angle=90.0,
|
||||
pose_type="pullup",
|
||||
):
|
||||
"""
|
||||
Configures the AIGym line_thickness, save image and view image parameters
|
||||
Args:
|
||||
|
|
@ -72,65 +74,75 @@ class AIGym:
|
|||
if frame_count == 1:
|
||||
self.count = [0] * len(results[0])
|
||||
self.angle = [0] * len(results[0])
|
||||
self.stage = ['-' for _ in results[0]]
|
||||
self.stage = ["-" for _ in results[0]]
|
||||
self.keypoints = results[0].keypoints.data
|
||||
self.annotator = Annotator(im0, line_width=2)
|
||||
|
||||
for ind, k in enumerate(reversed(self.keypoints)):
|
||||
if self.pose_type == 'pushup' or self.pose_type == 'pullup':
|
||||
self.angle[ind] = self.annotator.estimate_pose_angle(k[int(self.kpts_to_check[0])].cpu(),
|
||||
k[int(self.kpts_to_check[1])].cpu(),
|
||||
k[int(self.kpts_to_check[2])].cpu())
|
||||
if self.pose_type == "pushup" or self.pose_type == "pullup":
|
||||
self.angle[ind] = self.annotator.estimate_pose_angle(
|
||||
k[int(self.kpts_to_check[0])].cpu(),
|
||||
k[int(self.kpts_to_check[1])].cpu(),
|
||||
k[int(self.kpts_to_check[2])].cpu(),
|
||||
)
|
||||
self.im0 = self.annotator.draw_specific_points(k, self.kpts_to_check, shape=(640, 640), radius=10)
|
||||
|
||||
if self.pose_type == 'abworkout':
|
||||
self.angle[ind] = self.annotator.estimate_pose_angle(k[int(self.kpts_to_check[0])].cpu(),
|
||||
k[int(self.kpts_to_check[1])].cpu(),
|
||||
k[int(self.kpts_to_check[2])].cpu())
|
||||
if self.pose_type == "abworkout":
|
||||
self.angle[ind] = self.annotator.estimate_pose_angle(
|
||||
k[int(self.kpts_to_check[0])].cpu(),
|
||||
k[int(self.kpts_to_check[1])].cpu(),
|
||||
k[int(self.kpts_to_check[2])].cpu(),
|
||||
)
|
||||
self.im0 = self.annotator.draw_specific_points(k, self.kpts_to_check, shape=(640, 640), radius=10)
|
||||
if self.angle[ind] > self.poseup_angle:
|
||||
self.stage[ind] = 'down'
|
||||
if self.angle[ind] < self.posedown_angle and self.stage[ind] == 'down':
|
||||
self.stage[ind] = 'up'
|
||||
self.stage[ind] = "down"
|
||||
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "down":
|
||||
self.stage[ind] = "up"
|
||||
self.count[ind] += 1
|
||||
self.annotator.plot_angle_and_count_and_stage(angle_text=self.angle[ind],
|
||||
count_text=self.count[ind],
|
||||
stage_text=self.stage[ind],
|
||||
center_kpt=k[int(self.kpts_to_check[1])],
|
||||
line_thickness=self.tf)
|
||||
self.annotator.plot_angle_and_count_and_stage(
|
||||
angle_text=self.angle[ind],
|
||||
count_text=self.count[ind],
|
||||
stage_text=self.stage[ind],
|
||||
center_kpt=k[int(self.kpts_to_check[1])],
|
||||
line_thickness=self.tf,
|
||||
)
|
||||
|
||||
if self.pose_type == 'pushup':
|
||||
if self.pose_type == "pushup":
|
||||
if self.angle[ind] > self.poseup_angle:
|
||||
self.stage[ind] = 'up'
|
||||
if self.angle[ind] < self.posedown_angle and self.stage[ind] == 'up':
|
||||
self.stage[ind] = 'down'
|
||||
self.stage[ind] = "up"
|
||||
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "up":
|
||||
self.stage[ind] = "down"
|
||||
self.count[ind] += 1
|
||||
self.annotator.plot_angle_and_count_and_stage(angle_text=self.angle[ind],
|
||||
count_text=self.count[ind],
|
||||
stage_text=self.stage[ind],
|
||||
center_kpt=k[int(self.kpts_to_check[1])],
|
||||
line_thickness=self.tf)
|
||||
if self.pose_type == 'pullup':
|
||||
self.annotator.plot_angle_and_count_and_stage(
|
||||
angle_text=self.angle[ind],
|
||||
count_text=self.count[ind],
|
||||
stage_text=self.stage[ind],
|
||||
center_kpt=k[int(self.kpts_to_check[1])],
|
||||
line_thickness=self.tf,
|
||||
)
|
||||
if self.pose_type == "pullup":
|
||||
if self.angle[ind] > self.poseup_angle:
|
||||
self.stage[ind] = 'down'
|
||||
if self.angle[ind] < self.posedown_angle and self.stage[ind] == 'down':
|
||||
self.stage[ind] = 'up'
|
||||
self.stage[ind] = "down"
|
||||
if self.angle[ind] < self.posedown_angle and self.stage[ind] == "down":
|
||||
self.stage[ind] = "up"
|
||||
self.count[ind] += 1
|
||||
self.annotator.plot_angle_and_count_and_stage(angle_text=self.angle[ind],
|
||||
count_text=self.count[ind],
|
||||
stage_text=self.stage[ind],
|
||||
center_kpt=k[int(self.kpts_to_check[1])],
|
||||
line_thickness=self.tf)
|
||||
self.annotator.plot_angle_and_count_and_stage(
|
||||
angle_text=self.angle[ind],
|
||||
count_text=self.count[ind],
|
||||
stage_text=self.stage[ind],
|
||||
center_kpt=k[int(self.kpts_to_check[1])],
|
||||
line_thickness=self.tf,
|
||||
)
|
||||
|
||||
self.annotator.kpts(k, shape=(640, 640), radius=1, kpt_line=True)
|
||||
|
||||
if self.env_check and self.view_img:
|
||||
cv2.imshow('Ultralytics YOLOv8 AI GYM', self.im0)
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
cv2.imshow("Ultralytics YOLOv8 AI GYM", self.im0)
|
||||
if cv2.waitKey(1) & 0xFF == ord("q"):
|
||||
return
|
||||
|
||||
return self.im0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
AIGym()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue