MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / inference_video_based_model

Function inference_video_based_model

detrsmpl/apis/inference.py:204–292  ·  view source on GitHub ↗

Inference SMPL parameters from extracted featutres using a video-based model. Args: model (nn.Module): The loaded mesh estimation model. extracted_results (List[List[Dict]]): Multi-frame feature extraction results stored in a nested list. Each element of the oute

(model,
                                extracted_results,
                                with_track_id=True,
                                causal=True)

Source from the content-addressed store, hash-verified

202
203
204def inference_video_based_model(model,
205 extracted_results,
206 with_track_id=True,
207 causal=True):
208 """Inference SMPL parameters from extracted featutres using a video-based
209 model.
210
211 Args:
212 model (nn.Module): The loaded mesh estimation model.
213 extracted_results (List[List[Dict]]): Multi-frame feature extraction
214 results stored in a nested list. Each element of the outer list
215 is the feature extraction results of a single frame, and each
216 element of the inner list is the feature information of one person,
217 which contains:
218 features (ndarray): extracted features
219 track_id (int): unique id of each person, required when
220 ``with_track_id==True```
221 bbox ((4, ) or (5, )): left, right, top, bottom, [score]
222 with_track_id: If True, the element in extracted_results is expected to
223 contain "track_id", which will be used to gather the feature
224 sequence of a person from multiple frames. Otherwise, the extracted
225 results in each frame are expected to have a consistent number and
226 order of identities. Default is True.
227 causal (bool): If True, the target frame is the first frame in
228 a sequence. Otherwise, the target frame is in the middle of a
229 sequence.
230
231 Returns:
232 list[dict]: Each item in the list is a dictionary, which contains:
233 SMPL parameters, vertices, kp3d, and camera.
234 """
235 cfg = model.cfg
236 device = next(model.parameters()).device
237 seq_len = cfg.data.test.seq_len
238 mesh_results = []
239 # build the data pipeline
240 inference_pipeline = Compose(cfg.inference_pipeline)
241 target_idx = 0 if causal else len(extracted_results) // 2
242
243 input_features = _gather_input_features(extracted_results)
244 feature_sequences = _collate_feature_sequence(input_features,
245 with_track_id, target_idx)
246 if not feature_sequences:
247 return mesh_results
248
249 batch_data = []
250
251 for i, seq in enumerate(feature_sequences):
252
253 data = {
254 'features': seq['features'],
255 'sample_idx': i,
256 }
257
258 data = inference_pipeline(data)
259 batch_data.append(data)
260
261 batch_data = collate(batch_data, samples_per_gpu=len(batch_data))

Callers

nothing calls this directly

Calls 6

ComposeClass · 0.90
_gather_input_featuresFunction · 0.85
parametersMethod · 0.80
toMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected