MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / build_full_info_json

Method build_full_info_json

mbench/__init__.py:256–319  ·  view source on GitHub ↗

Build the full information JSON file for evaluation Args: evaluation_path: Path containing dimension folders with motion files name: Name for the evaluation run dimension_list: List of dimensions to evaluate **kwargs: Addition

(self, evaluation_path: str, name: str, 
                           dimension_list: List[str], **kwargs)

Source from the content-addressed store, hash-verified

254 print(f'Successfully rendered {rendered_count} unique motions across all categories')
255
256 def build_full_info_json(self, evaluation_path: str, name: str,
257 dimension_list: List[str], **kwargs) -> str:
258 """
259 Build the full information JSON file for evaluation
260
261 Args:
262 evaluation_path: Path containing dimension folders with motion files
263 name: Name for the evaluation run
264 dimension_list: List of dimensions to evaluate
265 **kwargs: Additional arguments
266
267 Returns:
268 Path to the created full info JSON file
269 """
270 cur_full_info_list = []
271 mbench_dir = self._get_mbench_dir(evaluation_path)
272
273 # Separate video-based, pose-quality (needs SMPLify .pt), and motion-quality (needs .npy) dimensions
274 video_dimension_list = ["Motion_Condition_Consistency", "Motion_Generalizability"]
275 pose_quality_dimension_list = ["Pose_Quality", "Body_Penetration"] # Need .pt with pose/vertices
276
277 video_dimensions = [dim for dim in dimension_list if dim in video_dimension_list]
278 pose_dimensions = [dim for dim in dimension_list if dim in pose_quality_dimension_list]
279 motion_dimensions = [dim for dim in dimension_list if dim not in video_dimensions and dim not in pose_dimensions]
280
281 full_info_list = load_json(self.full_info_dir)
282 for prompt_dict in full_info_list:
283 if prompt_dict["dimension"] in video_dimensions:
284 candidates = [
285 mbench_dir / f'{prompt_dict["id"]}.mp4',
286 self._find_source_video_path(evaluation_path, self.get_category(prompt_dict["dimension"]), prompt_dict["id"])
287 ]
288 elif prompt_dict["dimension"] in pose_dimensions:
289 # For pose_quality dimensions, need .pt files with pose/vertices (from SMPLify)
290 candidates = [
291 mbench_dir / f'{prompt_dict["id"]}.pt', # SMPLify output with pose/vertices
292 ]
293 elif prompt_dict["dimension"] in motion_dimensions:
294 # For motion_quality dimensions, check .npy first (raw joints), then .pt
295 candidates = [
296 mbench_dir / f'{prompt_dict["id"]}.npy', # Raw joints from organize script
297 mbench_dir / f'{prompt_dict["id"]}.pt', # Processed from SMPLify
298 ]
299 else:
300 candidates = []
301
302 evaluation_file = None
303 for candidate in candidates:
304 if candidate and Path(candidate).exists():
305 evaluation_file = str(candidate)
306 break
307
308 if evaluation_file is None:
309 print(f'WARNING: No evaluation file found for ID {prompt_dict["id"]} and dimension {prompt_dict["dimension"]}')
310 continue
311
312 prompt_copy = prompt_dict.copy()
313 prompt_copy["evaluation_file"] = evaluation_file

Callers 1

evaluateMethod · 0.95

Calls 5

_get_mbench_dirMethod · 0.95
get_categoryMethod · 0.95
load_jsonFunction · 0.85
save_jsonFunction · 0.85

Tested by

no test coverage detected