text stringlengths 0 1.47k |
|---|
# object type owns the whole directory. |
clip_prefix=('' if args.dataset_type == 'mixamo' |
else f'{object_type}-'), |
save_dir=args.save_dir, |
max_clip_len=args.max_clip_len, clip_stride=clip_stride, |
apply_clip=args.apply_clip, |
max_path_len=args.max_path_len, max_freqs=args.max_freqs, |
captions=resolve_captions(object_type, args.dataset_type, motion_captions), |
face_joints=face_joints, |
corps_names=(MIXAMO_CORE_JOINTS |
if args.dataset_type == 'mixamo' |
and args.mixamo_core_joints else None), |
clean_names=get_object_metadata(object_type, clean_joint_names), |
expected_names=get_object_metadata(object_type, joint_names), |
require_face=args.dataset_type == 'mixamo', |
target_diameter=args.target_diameter, |
use_tpos_ground_height=args.use_tpos_ground_height, |
activity_threshold=args.activity_threshold, |
static_threshold=args.static_threshold, |
min_frames=args.min_frames, |
jump_step_threshold=args.jump_step_threshold, |
jump_ratio_threshold=args.jump_ratio_threshold, |
min_joints=args.min_joints, max_joints=args.max_joints, |
save_vis=args.vis, vis_ground=args.vis_ground, |
adopt_legacy_cache=args.adopt_legacy_cache, |
)) |
return tasks |
def main(args): |
clip_stride = args.max_clip_len - args.diffusion_max_len |
if clip_stride <= 0: |
message = (f'--diffusion_max_len ({args.diffusion_max_len}) must be smaller ' |
f'than --max_clip_len ({args.max_clip_len}): the clip stride is ' |
f'their difference, and {clip_stride} would ' |
+ ('never advance the window' |
if clip_stride == 0 else 'walk the window backwards')) |
if args.apply_clip: |
raise ValueError(message) |
logger.warning(f'{message}. Harmless here because --apply_clip is off ' |
f'(the stride is unused), but fix it before enabling it.') |
os.makedirs(args.save_dir, exist_ok=True) |
motion_dir = pjoin(args.data_dir, 'motions') |
metadata = load_all_metadata(args.data_dir) |
logger.info(f'Loaded metadata from {args.data_dir}: ' |
+ ', '.join(f'{k}={len(v)}' for k, v in metadata.items())) |
check_metadata_object_types_consistent(metadata) |
category_groups = resolve_category_groups(args.category_groups, metadata) |
# Resolved up front so a bad --<v>_captions path fails before any work. |
extra_captions = {v: resolve_extra_captions(getattr(args, f'{v}_captions'), args.data_dir, v) |
for v in EXTRA_CAPTION_VERSIONS} |
tasks = build_object_tasks(args, clip_stride, motion_dir, metadata) |
cond = {} |
all_filtered_clips = {} |
clips_per_object = {} |
joints_per_object = {} |
total_frames = 0 |
max_njoints = 0 |
n_cached = 0 |
failed_objects = {} |
def accumulate(object_type, result, from_cache): |
nonlocal total_frames, max_njoints, n_cached |
n_cached += int(from_cache) |
if result.get('error'): |
failed_objects[object_type] = result['error'] |
if result['n_clips']: |
cond[object_type] = result['cond'] |
clips_per_object[object_type] = result['n_clips'] |
joints_per_object[object_type] = result['n_joints'] |
total_frames += result['n_frames'] |
max_njoints = max(max_njoints, result['n_joints']) |
if result['filtered']: |
all_filtered_clips[object_type] = result['filtered'] |
pbar = tqdm(total=len(tasks), desc="Processing objects", unit="obj") |
if args.num_workers > 1: |
with mp.Pool(args.num_workers) as pool: |
for object_type, result, from_cache in pool.imap_unordered( |
process_object_task, tasks): |
accumulate(object_type, result, from_cache) |
pbar.update(1) |
else: |
for task in tasks: |
accumulate(*process_object_task(task)) |
pbar.update(1) |
pbar.close() |
if n_cached: |
logger.info(f'Resumed {n_cached}/{len(tasks)} object types from cond_parts/ ' |
f'(delete that directory to force re-processing)') |
if failed_objects: |
logger.error(f'{len(failed_objects)}/{len(tasks)} object types failed and were ' |
f'skipped (retried on the next run); see ' |
f'{_error_log_path(args.save_dir)}: ' |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.