text stringlengths 0 1.47k |
|---|
params_hash = _params_hash(params) |
export_digest = _export_digest(task) |
task.pop('root_offsets', None) # cache key only; process_object reads the NPZs |
task.pop('rest_orientations', None) |
adopt_legacy = task.pop('adopt_legacy_cache', False) |
vis = _vis_record(task['save_vis'], task['vis_ground']) |
payload = _load_cached_payload(part_path, object_type, params, params_hash, |
export_digest, adopt_legacy=adopt_legacy) |
if payload is not None: |
if not task['save_vis'] or _previews_current(payload, task['save_dir'], |
clip_prefix, task['vis_ground']): |
return object_type, payload['result'], True |
status, value = _rebuild_with_previews(object_type, task, clip_prefix, |
part_path, payload, vis) |
if status == 'rebuilt': |
return object_type, value, False |
if status == 'kept': |
return object_type, payload['result'], True |
return object_type, _failed(object_type, task['save_dir'], value), False |
try: |
# The stale entry goes before the clips it describes: a run that |
# fails below must not leave an entry that a later run with the old |
# settings would reuse without its clips. |
if os.path.isfile(part_path): |
os.remove(part_path) |
shutil.rmtree(_rebuild_dir(task['save_dir'], object_type), ignore_errors=True) |
removed = _prune_object_clips(task['save_dir'], clip_prefix, task['save_vis']) |
if removed: |
logger.info(f'[{object_type}] removed {removed} clip files from a ' |
f'previous run before re-processing') |
obj_cond, n_clips, n_frames, n_joints, filtered = process_object( |
object_type, **task) |
except Exception as e: # noqa: BLE001 — keep the batch going |
logger.exception(f'[{object_type}] failed to process') |
return object_type, _failed(object_type, task['save_dir'], |
f'{type(e).__name__}: {e}'), False |
result = {'cond': obj_cond, 'n_clips': n_clips, 'n_frames': n_frames, |
'n_joints': n_joints, 'filtered': filtered} |
# Atomic: a worker killed mid-write can never leave a half-written cache |
# entry behind (unreadable ones are treated as misses, but this keeps them |
# from happening in the first place). |
atomic_np_save(part_path, {'params_hash': params_hash, 'params': params, |
'export_digest': export_digest, 'result': result, |
'vis': vis}) |
return object_type, result, False |
def build_object_tasks(args, clip_stride, motion_dir, metadata): |
face_joint_names = metadata.get('face_joint_names') |
clean_joint_names = metadata.get('clean_joint_names') |
joint_names = metadata.get('joint_names') |
motion_captions = metadata.get('motion_captions') |
object_types, all_motions = discover_object_types(motion_dir, args.dataset_type, args) |
trims_path = resolve_clip_trims_path(args.clip_trims, args.data_dir) |
clip_trims = load_clip_trims(trims_path) |
if clip_trims: |
stems = {m[:-4] for m in all_motions} |
missing = sorted(set(clip_trims) - stems) |
logger.info(f'Loaded {len(clip_trims)} head trims from {trims_path}' |
+ (f'; {len(missing)} name no motion being processed ' |
f'(filtered or absent): {missing[:5]}' if missing else '')) |
keep_path = resolve_activity_keep_path(args.activity_keep, args.data_dir) |
activity_keep = load_filtered_objects(keep_path) |
if activity_keep: |
stems = {m[:-4] for m in all_motions} |
missing = sorted(activity_keep - stems) |
logger.info(f'Loaded {len(activity_keep)} low-activity exemptions from {keep_path}' |
+ (f'; {len(missing)} name no motion being processed ' |
f'(filtered or absent): {missing[:5]}' if missing else '')) |
tasks = [] |
for object_type in object_types: |
object_npzs = collect_object_npzs(object_type, args.dataset_type, |
motion_dir, all_motions) |
head_trims = {s: clip_trims[s] for s in |
(os.path.basename(p)[:-4] for p in object_npzs) if s in clip_trims} |
keep = sorted(s for s in (os.path.basename(p)[:-4] for p in object_npzs) |
if s in activity_keep) |
face_joints = get_object_face_joints(object_type, face_joint_names) |
if not face_joints: |
if args.dataset_type == 'mixamo': |
raise ValueError(f'No face_joints entry for {object_type}; ' |
f'face_joint_names.json is required for mixamo') |
logger.info(f'No face_joints entry for {object_type}; using identity facing') |
tasks.append(dict( |
object_type=object_type, |
part_path=_object_part_path(args.save_dir, object_type), |
object_npzs=object_npzs, |
head_trims=head_trims, |
activity_keep=keep, |
root_offsets=read_root_offsets(object_npzs), |
rest_orientations=read_root_offsets(object_npzs, key=REST_ORIENTATION_KEY), |
# Mixamo clip files carry no "{object_type}-" prefix; its single |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.