text stringlengths 0 1.47k |
|---|
Only ``.npz`` files are considered, so stray side files in ``motions/`` |
never turn into object types with zero motions. |
""" |
entries = os.listdir(motion_dir) |
all_motions = [f for f in entries if f.endswith('.npz')] |
if len(all_motions) != len(entries): |
logger.info(f'Ignoring {len(entries) - len(all_motions)} non-NPZ ' |
f'entries in {motion_dir}') |
clips_path = resolve_filtered_clips_path(args.filtered_clips, args.data_dir) |
skip_clips = load_filtered_objects(clips_path) |
if skip_clips: |
before = len(all_motions) |
all_motions = [m for m in all_motions if m[:-4] not in skip_clips] |
logger.info(f'Loaded {len(skip_clips)} entries from {clips_path}; ' |
f'{before} -> {len(all_motions)} motion files after clip filtering') |
if dataset_type == 'mixamo': |
# Single object type; no prefix-based grouping. |
return [MIXAMO_OBJECT_TYPE], all_motions |
object_types = sorted(set(m.split('-')[0] for m in all_motions)) |
logger.info(f'Found {len(all_motions)} motion files, {len(object_types)} object types') |
if dataset_type in ('objaverse', 'general'): |
filtered_path = resolve_filtered_objects_path(args.filtered_objects, args.data_dir) |
filtered_object_types = load_filtered_objects(filtered_path) |
if filtered_object_types: |
before = len(object_types) |
object_types = [o for o in object_types if o not in filtered_object_types] |
logger.info(f'Loaded {len(filtered_object_types)} entries from {filtered_path}; ' |
f'{before} -> {len(object_types)} object types after filtering') |
elif args.filtered_objects: |
logger.info(f'No filtered_objects file found ' |
f'(--filtered_objects={args.filtered_objects!r}); ' |
f'processing all {len(object_types)} object types') |
return object_types, all_motions |
def collect_object_npzs(object_type, dataset_type, motion_dir, all_motions): |
if dataset_type == 'mixamo': |
return sorted(pjoin(motion_dir, f) for f in all_motions if f.endswith('.npz')) |
return sorted( |
pjoin(motion_dir, f) for f in all_motions |
if f.startswith(object_type + '-') and f.endswith('.npz') |
) |
def resolve_captions(object_type, dataset_type, motion_captions): |
# Mixamo caption keys are bare motion stems (no "{object_type}-" prefix), |
# so the full captions dict is passed through untouched. |
if dataset_type == 'mixamo': |
return motion_captions |
return get_object_captions(object_type, motion_captions) |
def _object_part_path(save_dir, object_type): |
return pjoin(save_dir, 'cond_parts', f'{object_type}.npy') |
def _error_log_path(save_dir): |
return pjoin(save_dir, 'extract_errors.log') |
# Settings that determine a cached object result's contents. A cache entry |
# built with different values is stale and gets re-processed. ``save_vis`` |
# is deliberately excluded: it only controls the MP4 previews, not the clips |
# or the cond. |
CACHE_PARAM_KEYS = ( |
'max_clip_len', 'clip_stride', 'apply_clip', |
'max_path_len', 'max_freqs', |
'target_diameter', 'activity_threshold', 'static_threshold', |
'min_frames', 'jump_step_threshold', 'jump_ratio_threshold', |
'min_joints', 'max_joints', |
'use_tpos_ground_height', |
'corps_names', |
) |
# Per-object METADATA inputs baked into the result (captions land in the |
# cond, face joints steer the facing canonicalization, clean names are |
# stored per joint). Hashed into the cache key so a stage-2/3 rerun — |
# new captions, corrected face pairs, recleaned labels — re-processes the |
# affected object types instead of silently resuming stale results. |
CACHE_DATA_KEYS = ('captions', 'face_joints', 'clean_names') |
def _digest(value): |
"""Stable short digest of a JSON-serializable metadata value.""" |
blob = json.dumps(value, sort_keys=True, default=str) |
return hashlib.sha1(blob.encode('utf-8')).hexdigest()[:16] |
def _cache_params(task): |
"""Extract the cache-invalidating settings from a task dict.""" |
params = {k: task[k] for k in CACHE_PARAM_KEYS} |
for k in CACHE_DATA_KEYS: |
params[f'{k}_digest'] = _digest(task[k]) |
# The object's source clip list. A clip added to the export or newly |
# listed in filtered_clips.txt must re-process the object: a cached |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.