Datasets:
File size: 1,873 Bytes
dd4d894 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #!/usr/bin/env python3
"""Generate ../metadata.csv (animations) and ../characters.csv from the JSON indexes.
Plain stdlib csv, so prompts containing commas/slashes are quoted correctly."""
import csv, json, os, sys
HERE=os.path.dirname(os.path.abspath(__file__)); ROOT=os.path.dirname(HERE)
J=lambda n: json.load(open(os.path.join(ROOT,n)))
prompts, frames = J("animation_prompts.json"), J("animation_frames.json")
rows=[]
for f in sorted(prompts):
v=prompts[f]
rows.append({
"file": "animation/"+f,
"prompt": v.get("prompt",""),
"description": v.get("description",""),
"text": v.get("description") or v.get("prompt",""), # ready-to-use label
"frames": frames.get(f,""),
"motion_id": v.get("motion_id",""),
})
out=os.path.join(ROOT,"metadata.csv")
with open(out,"w",newline="",encoding="utf-8") as fh:
w=csv.DictWriter(fh,fieldnames=["file","prompt","description","text","frames","motion_id"])
w.writeheader(); w.writerows(rows)
print("metadata.csv ->",len(rows),"rows")
chars, cbones = J("characters.json"), J("character_bones.json")
anim=set(J("animation_bones.json")["mixamo"])
crows=[]
for f in sorted(chars):
b=set(cbones.get(f,[]))
crows.append({
"file": "character_refined/"+f,
"file_original": "character/"+f,
"name": chars[f].get("name",""),
"uuid": chars[f].get("uuid",""),
"bone_count": len(b),
"covers_animation_rig": str(anim <= b).lower(),
})
out=os.path.join(ROOT,"characters.csv")
with open(out,"w",newline="",encoding="utf-8") as fh:
w=csv.DictWriter(fh,fieldnames=["file","file_original","name","uuid","bone_count","covers_animation_rig"])
w.writeheader(); w.writerows(crows)
n=sum(1 for r in crows if r["covers_animation_rig"]=="true")
print("characters.csv ->",len(crows),"rows |",n,"fully retargetable")
|