Safemotion Lib
Loading...
Searching...
No Matches
posec3d_kp_img.py
Go to the documentation of this file.
1model = dict(
2 type='ActionRecognitionRunner',
3 backbone=dict(
4 action_feat = dict(
5 type='ResNet3d',
6 in_channels = 17,
7 base_channels = 64,
8 stage_blocks = (4, 6, 3),
9 out_indices = (2, ),
10 spatial_strides = (2, 2, 2),
11 temporal_strides = (1, 1, 2),
12 dilations = (1, 1, 1),
13 conv1_kernel = (1, 7, 7),
14 conv1_stride_s = 1,
15 conv1_stride_t = 1,
16 pool1_stride_s = 1,
17 pool1_stride_t = 1,
18 inflate = (0, 1, 1),
19 inflate_style = '3x1x1',
20 input_key = 'pose_heatmap_for_action'
21 ),
22 pose_feat = dict(
23 type='ResNet3d',
24 in_channels = 17,
25 base_channels = 32,
26 stage_blocks = (4, 6, 3),
27 out_indices = (2, ),
28 spatial_strides = (2, 2, 2),
29 temporal_strides = (1, 1, 2),
30 dilations = (1, 1, 1),
31 conv1_kernel = (1, 7, 7),
32 conv1_stride_s = 1,
33 conv1_stride_t = 1,
34 pool1_stride_s = 1,
35 pool1_stride_t = 1,
36 inflate = (0, 1, 1),
37 inflate_style = '3x1x1',
38 input_key = 'pose_heatmap_for_pose'
39 ),
40 img_feat = dict(
41 type = 'ResNet2d',
42 in_channels = 768,
43 stage_blocks = [2, 2, 2, 2],
44 input_key = 'image_feature',
45 ),
46 ),
47 fusion=dict(
48 type='CatLayer',
49 input_key = ['action_feat', 'pose_feat', 'img_feat'],
50 input_type = ['3d', '3d', '2d'],
51 ),
52 head=dict(
53 action_upper = dict(
54 type='LinearHead',
55 in_channels=1024+512+768,
56 num_classes=6,
57 dropout_ratio=0.5,
58 input_key = 'fusion',
59 ),
60 action_lower = dict(
61 type='LinearHead',
62 in_channels=1024+512+768,
63 num_classes=12,
64 dropout_ratio=0.5,
65 input_key = 'fusion',
66 ),
67 pose = dict(
68 type='MLPHead',
69 in_channels=1024+512+768,
70 num_classes=8,
71 layer_channels=[2048],
72 dropout_ratio=0.5,
73 input_key = 'fusion',
74 ),
75 hand = dict(
76 type='MLPHead',
77 in_channels=1024+512+768,
78 num_classes=4,
79 layer_channels=[2048],
80 dropout_ratio=0.5,
81 input_key = 'fusion',
82 ),
83 foot = dict(
84 type='MLPHead',
85 in_channels=1024+512+768,
86 num_classes=2,
87 layer_channels=[2048],
88 dropout_ratio=0.5,
89 input_key = 'fusion',
90 ),
91 aux_action_upper = dict(
92 type='I3DHead',
93 in_channels=1024,
94 num_classes=6,
95 dropout_ratio=0.5,
96 input_key = 'action_feat',
97 ),
98 aux_action_lower = dict(
99 type='I3DHead',
100 in_channels=1024,
101 num_classes=12,
102 dropout_ratio=0.5,
103 input_key = 'action_feat',
104 ),
105 aux_pose = dict(
106 type='MLPHead',
107 in_channels=512,
108 num_classes=8,
109 layer_channels=[1024],
110 dropout_ratio=0.5,
111 input_key = 'pose_feat',
112 input_type = '3d',
113 ),
114 aux_hand = dict(
115 type='MLPHead',
116 in_channels=512,
117 num_classes=4,
118 layer_channels=[1024],
119 dropout_ratio=0.5,
120 input_key = 'pose_feat',
121 input_type = '3d',
122 ),
123 aux_foot = dict(
124 type='MLPHead',
125 in_channels=512,
126 num_classes=2,
127 layer_channels=[1024],
128 dropout_ratio=0.5,
129 input_key = 'pose_feat',
130 input_type = '3d',
131 ),
132 ),
133 predict_keys = dict(
134 #예측한 라벨의 키 = 헤드의 키(스코어의 키)
135 pred_action_upper = 'action_upper',
136 pred_action_lower = 'action_lower',
137 pred_pose = 'pose',
138 pred_hand = 'hand',
139 pred_foot = 'foot',
140 )
141)
142
143score_keys = ['action_upper', 'action_lower', 'pose', 'hand', 'foot', 'aux_action_upper', 'aux_action_lower', 'aux_pose', 'aux_hand', 'aux_foot']
144pred_keys = ['pred_action_upper', 'pred_action_lower', 'pred_pose', 'pred_hand', 'pred_foot']
145gt_keys = ['gt_action_upper', 'gt_action_lower', 'gt_pose', 'gt_hand', 'gt_foot', 'gt_action_upper', 'gt_action_lower', 'gt_pose', 'gt_hand', 'gt_foot']
146target_tasks = ['action_upper', 'action_lower', 'pose', 'hand', 'foot', 'action_upper', 'action_lower', 'pose', 'hand', 'foot']
147train_tasks = ['action_upper', 'action_lower', 'pose', 'hand', 'foot']
148
149
150loss = dict(
151 MutiTaskSigmoidFocalLoss = dict(
152 weight = 1.0,
153 task_key = 'category',
154 pred_keys = score_keys,
155 gt_keys = gt_keys,
156 target_tasks = target_tasks,
157 weights = [1.0, 1.0, 1.0, 1.0, 1.0, 0.25, 0.25, 0.25, 0.25, 0.25],
158 # data_num = dict(action = [100, 100, 100, 24, 100, 34, 3, 100, 100], pose = [98, 517, 11, 35])
159 )
160)
161
162metric_args = dict(pred_key=pred_keys,
163 gt_key=gt_keys[:5],
164 target_tasks=target_tasks[:5],
165 task_key='category')
166
167collect_keys = ['pose_heatmap_for_action', 'pose_heatmap_for_pose', 'image_feature', 'gt_action_upper', 'gt_action_lower', 'gt_pose', 'gt_hand', 'gt_foot']
168
169data_loader = dict(
170 type = 'ActionDatasetLoader_mtml',
171 data_folder = '/media/safemotion/HDD5/pjm_test/action_train_dataset_2023/action_kp_imf_split',
172 category_info = dict(action_upper = 6,
173 action_lower = 12,
174 pose = 8,
175 hand = 4,
176 foot = 2),
177 clip_len_action = 20,
178 clip_len_pose = 6,
179)
180ep_mul = 20
181train = dict(
182 num_workers = 8,
183 init_lr = 0.1,
184 batch_size = 32,
185 epochs = 100*ep_mul,
186 optimizer = 'SGD',
187 optimizer_args = dict(momentum=0.9, nesterov=True, weight_decay=0.0001),
188 scheduler = 'CosineAnnealingLR',
189 # scheduler = 'StepLR',
190 scheduler_args = dict(T_max=30*ep_mul, eta_min=0),
191 adjust_lr_epoch = [10*ep_mul, 50*ep_mul, 100*ep_mul, 130*ep_mul],
192 adjust_lr_rate = [0.5, 0.1, 0.1, 0.1],
193 val_interval = 1,
194
195
196 update_loss_weight = False,
197 update_loss_weight_interval = 20,
198 base_weight = 0.5,
199
200 pretrained = None,#'/media/safemotion/HDD5/pjm_test/action_train_test/9.pth',
201 save_root = '/media/safemotion/HDD5/pjm_test/action_train_result/action_kp_img',
202
203)
204
205test = dict(
206 model_path = None,
207 save_root = '',
208)