Safemotion Lib
Loading...
Searching...
No Matches
Functions | Variables
action_demo_with_anno Namespace Reference

Functions

 make_pose_result (anno_data)
 

Variables

list sys_path = ['/workspace/smlab', '/workspace']
 
 action_vis_param
 
 vis_param
 
str action_cfg_path = '/workspace/InnoTest/models/posec3d_action.py'
 
str posture_cfg_path = '/workspace/InnoTest/models/posec3d_pose.py'
 
str image_base = '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/images'
 
str save_root = '/media/safemotion/HDD5/pjm_test/inno2023_result_select_half'
 
list anno_folder_list
 
list cvt_lower_map = [0, 1, 2, 0, 4, 5, 6, 7, 8, 9, 0, 11]
 
list cvt_upper_map = [0, 0, 0, 3, 4, 0]
 
list cvt_pose_map = [0, 0, 0, 0, 4, 4, 6, 7]
 
list cvt_hand_map = [0, 0, 0, 3]
 
str device = 'cuda:0'
 
 action_model = smrunner.build_model(action_cfg_path).to(device)
 
 posture_model = smrunner.build_model(posture_cfg_path).to(device)
 
 labelmap = dict()
 
list json_path_list = []
 
 name_list
 
 path_list
 
 NUM = len(json_path_list)
 
int video_fps = 30
 
int action_k = video_fps*2
 
int action_sample = 20
 
int pose_k = video_fps//2
 
int pose_sample = 6
 
 data_manager = AnnotationDataManager()
 
 json_name = json_path.split('/')[-1]
 
 save_folder = os.path.join(save_root, json_name.split('.')[0])
 
 save_video_path = os.path.join(save_root, json_name.replace('.json', '.mp4'))
 
 json_path
 
dict track_data = {}
 
int frame_id = 0
 
 end
 
 anno_data = data_manager.get_anno_data_in_image(filter=True)
 
 image = data_manager.read_image()
 
 vis_img = image.copy()
 
 pose_result = make_pose_result(anno_data)
 
 track_id = int(pose['track_id'])
 
list delete_list = []
 
int txt_pos_y = 50
 
 bbox = pose_q[-1]['bbox']
 
 last_frame = pose_q[-1]['frame_id']
 
str label = f'{track_id:3d}'
 
 action_result = action_model.run_recognizer(pose_q, action_k, action_sample, device=device)
 
 posture_result = posture_model.run_recognizer(pose_q[-pose_k:], pose_k, pose_sample, False, device=device)
 
list pose_label = cvt_pose_map[posture_result['pred_pose']]
 
list upper_label = cvt_upper_map[action_result['pred_action_upper']]
 
list lower_label = cvt_lower_map[action_result['pred_action_lower']]
 
list hand_label = cvt_hand_map[posture_result['pred_hand']]
 
str name = f'{frame_id:06d}.jpg'
 
 save_path = os.path.join(save_folder, name)
 
 fps
 
 half
 

Function Documentation

◆ make_pose_result()

action_demo_with_anno.make_pose_result ( anno_data)

Definition at line 26 of file action_demo_with_anno.py.

26def make_pose_result(anno_data):
27 pose_result = []
28 for anno in anno_data:
29 tmp_data = {}
30
31 box = copy.deepcopy(anno['bbox'])
32
33 tmp_data['bbox'] = np.array(box)
34 tmp_data['keypoints'] = np.array(anno['keypoints'])
35 tmp_data['track_id'] = anno['track_id']
36 pose_result.append(tmp_data)
37
38 return pose_result
39
40#시각화 파라미터

Variable Documentation

◆ action_cfg_path

str action_demo_with_anno.action_cfg_path = '/workspace/InnoTest/models/posec3d_action.py'

Definition at line 60 of file action_demo_with_anno.py.

◆ action_k

int action_demo_with_anno.action_k = video_fps*2

Definition at line 110 of file action_demo_with_anno.py.

◆ action_model

action_demo_with_anno.action_model = smrunner.build_model(action_cfg_path).to(device)

Definition at line 88 of file action_demo_with_anno.py.

◆ action_result

action_demo_with_anno.action_result = action_model.run_recognizer(pose_q, action_k, action_sample, device=device)

Definition at line 185 of file action_demo_with_anno.py.

◆ action_sample

int action_demo_with_anno.action_sample = 20

Definition at line 111 of file action_demo_with_anno.py.

◆ action_vis_param

action_demo_with_anno.action_vis_param
Initial value:
1= dict(
2 box_color = (0, 255, 0),
3 box_thk = 3,
4 txt_color = (255, 255, 255),
5 txt_thk=3,
6 txt_scale=1.5,
7 box_type='xyxy'
8)

Definition at line 41 of file action_demo_with_anno.py.

◆ anno_data

action_demo_with_anno.anno_data = data_manager.get_anno_data_in_image(filter=True)

Definition at line 139 of file action_demo_with_anno.py.

◆ anno_folder_list

list action_demo_with_anno.anno_folder_list
Initial value:
1= [
2 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_kid_1',
3 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_kid_kkomo_1',
4 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_kid_kkumjalam_1',
5 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_kid_kkumjalam_hard_1',
6 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_kid_kkomo_2',
7 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_kid_kkumjalam_hard_1'
8 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_2nd_3',
9 '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/annotations_action_v22_2nd_4',
10]

Definition at line 66 of file action_demo_with_anno.py.

◆ bbox

action_demo_with_anno.bbox = pose_q[-1]['bbox']

Definition at line 166 of file action_demo_with_anno.py.

◆ cvt_hand_map

list action_demo_with_anno.cvt_hand_map = [0, 0, 0, 3]

Definition at line 81 of file action_demo_with_anno.py.

◆ cvt_lower_map

list action_demo_with_anno.cvt_lower_map = [0, 1, 2, 0, 4, 5, 6, 7, 8, 9, 0, 11]

Definition at line 78 of file action_demo_with_anno.py.

◆ cvt_pose_map

list action_demo_with_anno.cvt_pose_map = [0, 0, 0, 0, 4, 4, 6, 7]

Definition at line 80 of file action_demo_with_anno.py.

◆ cvt_upper_map

list action_demo_with_anno.cvt_upper_map = [0, 0, 0, 3, 4, 0]

Definition at line 79 of file action_demo_with_anno.py.

◆ data_manager

action_demo_with_anno.data_manager = AnnotationDataManager()

Definition at line 116 of file action_demo_with_anno.py.

◆ delete_list

list action_demo_with_anno.delete_list = []

Definition at line 162 of file action_demo_with_anno.py.

◆ device

str action_demo_with_anno.device = 'cuda:0'

Definition at line 87 of file action_demo_with_anno.py.

◆ end

action_demo_with_anno.end

Definition at line 136 of file action_demo_with_anno.py.

◆ fps

action_demo_with_anno.fps

Definition at line 240 of file action_demo_with_anno.py.

◆ frame_id

int action_demo_with_anno.frame_id = 0

Definition at line 133 of file action_demo_with_anno.py.

◆ half

action_demo_with_anno.half

Definition at line 240 of file action_demo_with_anno.py.

◆ hand_label

list action_demo_with_anno.hand_label = cvt_hand_map[posture_result['pred_hand']]

Definition at line 202 of file action_demo_with_anno.py.

◆ image

action_demo_with_anno.image = data_manager.read_image()

Definition at line 142 of file action_demo_with_anno.py.

◆ image_base

action_demo_with_anno.image_base = '/media/safemotion/HDD2/SM_Dataset/action_2022/action_cctv_img/images'

Definition at line 62 of file action_demo_with_anno.py.

◆ json_name

action_demo_with_anno.json_name = json_path.split('/')[-1]

Definition at line 122 of file action_demo_with_anno.py.

◆ json_path

action_demo_with_anno.json_path

Definition at line 128 of file action_demo_with_anno.py.

◆ json_path_list

list action_demo_with_anno.json_path_list = []

Definition at line 101 of file action_demo_with_anno.py.

◆ label

str action_demo_with_anno.label = f'{track_id:3d}'

Definition at line 170 of file action_demo_with_anno.py.

◆ labelmap

action_demo_with_anno.labelmap = dict()

Definition at line 94 of file action_demo_with_anno.py.

◆ last_frame

action_demo_with_anno.last_frame = pose_q[-1]['frame_id']

Definition at line 168 of file action_demo_with_anno.py.

◆ lower_label

list action_demo_with_anno.lower_label = cvt_lower_map[action_result['pred_action_lower']]

Definition at line 201 of file action_demo_with_anno.py.

◆ name

str action_demo_with_anno.name = f'{frame_id:06d}.jpg'

Definition at line 235 of file action_demo_with_anno.py.

◆ name_list

action_demo_with_anno.name_list

Definition at line 103 of file action_demo_with_anno.py.

◆ NUM

action_demo_with_anno.NUM = len(json_path_list)

Definition at line 105 of file action_demo_with_anno.py.

◆ path_list

action_demo_with_anno.path_list

Definition at line 103 of file action_demo_with_anno.py.

◆ pose_k

int action_demo_with_anno.pose_k = video_fps//2

Definition at line 112 of file action_demo_with_anno.py.

◆ pose_label

list action_demo_with_anno.pose_label = cvt_pose_map[posture_result['pred_pose']]

Definition at line 199 of file action_demo_with_anno.py.

◆ pose_result

action_demo_with_anno.pose_result = make_pose_result(anno_data)

Definition at line 149 of file action_demo_with_anno.py.

◆ pose_sample

int action_demo_with_anno.pose_sample = 6

Definition at line 113 of file action_demo_with_anno.py.

◆ posture_cfg_path

str action_demo_with_anno.posture_cfg_path = '/workspace/InnoTest/models/posec3d_pose.py'

Definition at line 61 of file action_demo_with_anno.py.

◆ posture_model

action_demo_with_anno.posture_model = smrunner.build_model(posture_cfg_path).to(device)

Definition at line 89 of file action_demo_with_anno.py.

◆ posture_result

action_demo_with_anno.posture_result = posture_model.run_recognizer(pose_q[-pose_k:], pose_k, pose_sample, False, device=device)

Definition at line 191 of file action_demo_with_anno.py.

◆ save_folder

action_demo_with_anno.save_folder = os.path.join(save_root, json_name.split('.')[0])

Definition at line 123 of file action_demo_with_anno.py.

◆ save_path

action_demo_with_anno.save_path = os.path.join(save_folder, name)

Definition at line 236 of file action_demo_with_anno.py.

◆ save_root

str action_demo_with_anno.save_root = '/media/safemotion/HDD5/pjm_test/inno2023_result_select_half'

Definition at line 63 of file action_demo_with_anno.py.

◆ save_video_path

action_demo_with_anno.save_video_path = os.path.join(save_root, json_name.replace('.json', '.mp4'))

Definition at line 124 of file action_demo_with_anno.py.

◆ sys_path

list action_demo_with_anno.sys_path = ['/workspace/smlab', '/workspace']

Definition at line 4 of file action_demo_with_anno.py.

◆ track_data

dict action_demo_with_anno.track_data = {}

Definition at line 132 of file action_demo_with_anno.py.

◆ track_id

action_demo_with_anno.track_id = int(pose['track_id'])

Definition at line 153 of file action_demo_with_anno.py.

◆ txt_pos_y

int action_demo_with_anno.txt_pos_y = 50

Definition at line 163 of file action_demo_with_anno.py.

◆ upper_label

list action_demo_with_anno.upper_label = cvt_upper_map[action_result['pred_action_upper']]

Definition at line 200 of file action_demo_with_anno.py.

◆ video_fps

action_demo_with_anno.video_fps = 30

Definition at line 109 of file action_demo_with_anno.py.

◆ vis_img

action_demo_with_anno.vis_img = image.copy()

Definition at line 145 of file action_demo_with_anno.py.

◆ vis_param

action_demo_with_anno.vis_param
Initial value:
1= dict(
2 box_color = (0, 255, 0),
3 box_thk = 3,
4 txt_color = (255, 255, 255),
5 txt_thk=3,
6 txt_scale=1.5,
7 box_type='xyxy'
8)

Definition at line 50 of file action_demo_with_anno.py.