Safemotion Lib
Loading...
Searching...
No Matches
pose_demo.py
Go to the documentation of this file.
1#system path 설정
2import sys
3sys_path = ['/workspace/smlab', '/workspace']
4for path in sys_path:
5 if path not in sys.path:
6 sys.path.append(path)
7
8#import package
9import cv2
10import smrunner
11from smutils.utils_vis import vis_pose_coco_skeleton
12
13#경로 설정
14cfg_path = '/workspace/smlab/smpose/configs/mmpose/hrnet_trt.py' # hrnet
15image_path = '/workspace/smlab/smpose/demo/human-pose.jpg'
16save_path = '/workspace/smlab/smpose/demo/skeleton.jpg'
17
18# 모델 빌드
19pose_model = smrunner.build_model(cfg_path)
20
21# 이미지 로드
22image = cv2.imread(image_path)
23
24# 모델 inference
25result = pose_model.run_detector(image)
26
27#시각화 영상 만들기 및 저장
28vis_img = image.copy()
29vis_img = vis_pose_coco_skeleton(image, result)
30cv2.imwrite(save_path, vis_img)
31
32#모델 결과 출력
33print(result)