text stringlengths 0 1.47k |
|---|
# type: (str) -> Optional[Dict[str, str]] |
"""Load motion captions from ``motion_captions.json`` in *source_dir*.""" |
return load_json(pjoin(source_dir, 'motion_captions.json')) |
# Extra caption versions beside the normal one (``motion_captions.json`` -> |
# ``captions.json``): the short generic caption and the longer detail caption, |
# HumanML3D-style. Each comes only from its reviewed patch file through |
# ``patch_annotations.py`` (export ``motion_captions_<v>.json``) and is saved by |
# stage 4 as ``captions_<v>.json``; training may sample one per step. |
EXTRA_CAPTION_VERSIONS = ('generic', 'detail') |
def load_extra_captions(source_dir, version): |
# type: (str, str) -> Optional[Dict[str, str]] |
"""Load one extra caption version from ``motion_captions_<version>.json`` |
(written by ``patch_annotations.py``; None when the export has none).""" |
if version not in EXTRA_CAPTION_VERSIONS: |
raise ValueError(f'unknown caption version {version!r}; ' |
f'expected one of {EXTRA_CAPTION_VERSIONS}') |
return load_json(pjoin(source_dir, f'motion_captions_{version}.json')) |
def load_generic_captions(source_dir): |
# type: (str) -> Optional[Dict[str, str]] |
"""``load_extra_captions(source_dir, 'generic')``.""" |
return load_extra_captions(source_dir, 'generic') |
def by_feature_key(feature_captions, export_captions): |
# type: (Dict[str, str], Dict[str, str]) -> Dict[str, str] |
"""Re-key an export ``{clip: caption}`` map (normal, generic or detail) by |
the feature clip keys. |
Feature keys are ``<export clip>-<NNN>`` (one per saved segment), the keys |
of ``captions.json``; every segment of a clip gets the clip's caption. |
Feature clips without an export caption are left out. |
""" |
out = {} |
for key in feature_captions: |
stem = key.rsplit('-', 1)[0] |
if stem in export_captions: |
out[key] = export_captions[stem] |
return out |
def load_category_groups(source_dir): |
# type: (str) -> Optional[Dict[str, List[str]]] |
"""Load category-to-object-type groupings from ``category_groups.json``.""" |
return load_json(pjoin(source_dir, 'category_groups.json')) |
def load_clean_joint_names(source_dir): |
# type: (str) -> Optional[Dict[str, List[str]]] |
"""Load cleaned joint names from ``clean_joint_names.json``.""" |
return load_json(pjoin(source_dir, 'clean_joint_names.json')) |
def load_face_joint_names(source_dir): |
# type: (str) -> Optional[Dict[str, dict]] |
"""Load face joint info from ``face_joint_names.json``.""" |
return load_json(pjoin(source_dir, 'face_joint_names.json')) |
# The 22-joint humanoid core the mixamo rig is reduced to at extraction time |
# (drops the 40 finger bones plus the End bones); toggled by --mixamo_core_joints. |
MIXAMO_CORE_JOINTS = [ |
"mixamorig:Hips", |
"mixamorig:Spine", "mixamorig:Spine1", "mixamorig:Spine2", |
"mixamorig:Neck", "mixamorig:Head", |
"mixamorig:LeftShoulder", "mixamorig:LeftArm", |
"mixamorig:LeftForeArm", "mixamorig:LeftHand", |
"mixamorig:RightShoulder", "mixamorig:RightArm", |
"mixamorig:RightForeArm", "mixamorig:RightHand", |
"mixamorig:LeftUpLeg", "mixamorig:LeftLeg", |
"mixamorig:LeftFoot", "mixamorig:LeftToeBase", |
"mixamorig:RightUpLeg", "mixamorig:RightLeg", |
"mixamorig:RightFoot", "mixamorig:RightToeBase", |
] |
def load_joint_names(source_dir): |
# type: (str) -> Optional[Dict[str, List[str]]] |
"""Load raw joint names from ``joint_names.json``.""" |
return load_json(pjoin(source_dir, 'joint_names.json')) |
def load_all_metadata(source_dir): |
# type: (str) -> dict |
"""Load all available JSON metadata files from *source_dir*.""" |
loaders = { |
'motion_captions': load_motion_captions, |
'category_groups': load_category_groups, |
'clean_joint_names': load_clean_joint_names, |
'face_joint_names': load_face_joint_names, |
'joint_names': load_joint_names, |
} |
meta = {} |
for key, loader in loaders.items(): |
data = loader(source_dir) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.