text stringlengths 0 1.47k |
|---|
help='Only these object types (Mixamo: character names).') |
ap.add_argument('--overwrite', action='store_true', |
help='Rebuild even the GLBs whose inputs are unchanged.') |
ap.add_argument('--worker_id', type=int, default=0) |
ap.add_argument('--num_workers', type=int, default=1) |
argv = sys.argv[sys.argv.index('--') + 1:] if '--' in sys.argv else sys.argv[1:] |
return ap.parse_args(argv) |
def main(): |
args = parse_args() |
counts = bake_canonical_assets( |
args.export_dir, args.features_dir, assets_dir=args.assets_dir, |
dataset_type=args.dataset_type, |
object_types=args.object_types, worker_id=args.worker_id, |
num_workers=args.num_workers, overwrite=args.overwrite) |
return 1 if counts['failed'] else 0 |
if __name__ == '__main__': |
sys.exit(main()) |
# ===== file: data_process/feature_extraction/extract_features.py ===== |
"""Process exported NPZ motions into canonicalized training clips. |
Supports four dataset layouts via ``--dataset_type``: |
- ``truebones``: per-object NPZ files under ``data_dir/motions``, named |
``{object_type}-{motion}.npz``. Object types are discovered from filename |
prefixes. |
- ``objaverse``: same layout as truebones, plus an optional |
``filtered_objects.txt`` listing object types to skip. |
- ``general``: extra assets of your own (``dataset/raw/general/animation``, exported by |
``export_general.py``); processed exactly like ``objaverse``. |
- ``mixamo``: single skeleton / object type. All NPZs live directly under |
``data_dir/motions`` with no ``{object_type}-`` prefix; caption keys are |
bare motion stems. |
An optional ``filtered_clips.txt`` listing individual clips to skip is read |
for every layout, and an optional ``clip_trims.txt`` (``<clip stem> <N>``) |
drops the first N frames of a clip's export NPZ on load, and an optional |
``activity_keep.txt`` exempts listed clips from the low-activity filter. All |
three are generated from the hand-reviewed patches by |
``tools/patch_annotations.py``. |
Stage-2 (captions, category groups) and stage-3 (clean / face joint names) |
metadata JSONs are read from ``data_dir`` — see |
:mod:`data_process.feature_extraction.metadata`. Every clip has up to three |
captions: the normal one (``motion_captions.json`` -> ``captions.json``; |
a clip without one is still saved, but left out of ``captions.json``, and the |
training loader skips it) and, when the export has them, a short |
generic and a longer detail one (``motion_captions_<v>.json`` -> |
``captions_<v>.json``, see ``--generic_captions`` / ``--detail_captions``). |
Training can sample any of them per step. |
Object types are independent, so they can be processed in parallel |
(``--num_workers``) and are resumable: each finished object type caches its |
result under ``<save_dir>/cond_parts/`` and is skipped on rerun. The cache |
records the clip / threshold / topology settings and the export files (name, |
size, mtime) it was built from and is re-processed automatically when they |
change; delete ``cond_parts/`` (or one entry) to force re-processing for any |
other reason. An entry that does not record the export files is re-processed |
too, unless ``--adopt_legacy_cache`` vouches that the export has not changed |
since it was written. With ``--vis``, a cached object whose previews are |
missing, were made with another ``--vis_ground`` or with unrecorded settings |
is processed again into a temporary directory, and its outputs replace the |
cached ones only when every clip got its preview. |
Object types that fail are logged to ``<save_dir>/extract_errors.log``, |
recorded in ``filtered_clips.json`` and skipped (no cache entry is written, |
so they are retried on the next run) — one bad object never aborts the run. |
Usage: |
python -m data_process.feature_extraction.extract_features \\ |
--dataset_type truebones \\ |
--data_dir dataset/export/truebones \\ |
--save_dir dataset/features/truebones |
""" |
import argparse |
import hashlib |
import json |
import multiprocessing as mp |
import os |
import shutil |
import zipfile |
from os.path import join as pjoin |
import numpy as np |
from loguru import logger |
from tqdm import tqdm |
from data_process.feature_extraction.metadata import ( |
EXTRA_CAPTION_VERSIONS, |
MIXAMO_CORE_JOINTS, |
atomic_np_save, |
build_stats, |
check_metadata_object_types_consistent, |
get_object_captions, |
get_object_face_joints, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.