Download preprocess/attach_flame.py from tsinghua-ee/ELLSA2_data: direct link, hf CLI and curl.
- Browser
- Download file 1.52 kB
-
https://huggingface.co/datasets/tsinghua-ee/ELLSA2_data/resolve/main/preprocess/attach_flame.py
- Command line
-
hf download hf://datasets/tsinghua-ee/ELLSA2_data/preprocess/attach_flame.py
-
curl -L -o attach_flame.py https://huggingface.co/datasets/tsinghua-ee/ELLSA2_data/resolve/main/preprocess/attach_flame.py
1.52 kB
| """Attach extracted raw FLAME files and keep samples with both modalities.""" | |
| import argparse | |
| import json | |
| from pathlib import Path | |
| def rows(obj): | |
| return obj["data"] if isinstance(obj, dict) else obj | |
| def main(): | |
| p = argparse.ArgumentParser() | |
| p.add_argument("--input", required=True) | |
| p.add_argument("--flame-manifest", required=True, help="JSON rows with pose_file and raw flame_file") | |
| p.add_argument("--output", required=True) | |
| a = p.parse_args() | |
| data = rows(json.loads(Path(a.input).read_text())) | |
| flame = rows(json.loads(Path(a.flame_manifest).read_text())) | |
| index = {} | |
| for row in flame: | |
| stem = Path(row["pose_file"]).stem | |
| if stem in index: | |
| raise ValueError(f"Ambiguous FLAME pairing for pose stem: {stem}") | |
| index[stem] = row | |
| selected = [] | |
| for r in data: | |
| entry = index.get(Path(r["pose_file"]).stem) | |
| if entry is None: | |
| continue | |
| path = entry.get("flame_file_original", entry.get("flame_file")) | |
| if not path or not Path(path).is_file(): | |
| continue | |
| selected.append(dict({key: value for key, value in r.items() if not key.startswith('flame_')}, | |
| flame_file=path)) | |
| assert selected, "No paired SMPL-H / FLAME samples remain" | |
| Path(a.output).parent.mkdir(parents=True, exist_ok=True) | |
| Path(a.output).write_text(json.dumps({"data": selected}, indent=2)) | |
| print(f"Kept {len(selected)} / {len(data)} samples") | |
| if __name__ == "__main__": | |
| main() | |