| |
| """Integrity check of the mixamo/ dataset (run from mixamo/scripts/). |
| Usage: python3 validate.py # structural + JSON checks (offline) |
| python3 validate.py <tokfile> # + sampled Mixamo API cross-check |
| Structural (corruption), JSON completeness+correctness, optional API cross-check.""" |
| import json, os, sys, random, time |
| HERE = os.path.dirname(os.path.abspath(__file__)) |
| sys.path.insert(0, HERE) |
| from fbx_frames import parse as fbxparse |
| ROOT = os.path.dirname(HERE) |
| ADIR, CDIR = os.path.join(ROOT,"animation"), os.path.join(ROOT,"character") |
| tokfile = sys.argv[1] if len(sys.argv) > 1 else None |
| MAGIC = b"Kaydara FBX Binary" |
| problems = [] |
| def bad(m): problems.append(m); print(" ✗", m) |
|
|
| def scan(d, need_mesh): |
| s={"count":0,"header":[],"parse":[],"tiny":[],"norig":[],"nomesh":[],"frames":{}} |
| for f in sorted(os.listdir(d)): |
| if not f.endswith(".fbx"): continue |
| p=os.path.join(d,f); s["count"]+=1 |
| if MAGIC not in open(p,"rb").read(64): s["header"].append(f); continue |
| if os.path.getsize(p) < 2000: s["tiny"].append(f) |
| try: s["frames"][f]=fbxparse(p)["keys_max"] |
| except Exception as e: s["parse"].append((f,str(e)[:40])); continue |
| blob=open(p,"rb").read() |
| if b"LimbNode" not in blob: s["norig"].append(f) |
| if need_mesh and blob.count(b"Vertices")<1: s["nomesh"].append(f) |
| return s |
|
|
| print("=== 1. STRUCTURAL animation ==="); a=scan(ADIR,False) |
| print(" FBX:",a["count"]) |
| for k,l in [("header","bad header"),("parse","parse fail"),("tiny","too small"),("norig","no skeleton")]: |
| if a[k]: bad("%d %s: %s"%(len(a[k]),l,a[k][:5])) |
| if not any(a[k] for k in ("header","parse","tiny","norig")): print(" ✓ all valid, rigged, non-truncated") |
|
|
| print("=== 2. STRUCTURAL character ==="); c=scan(CDIR,True) |
| print(" FBX:",c["count"]) |
| for k,l in [("header","bad header"),("parse","parse fail"),("tiny","too small"),("nomesh","no skin mesh")]: |
| if c[k]: bad("%d %s: %s"%(len(c[k]),l,c[k][:5])) |
| if not any(c[k] for k in ("header","parse","tiny","nomesh")): print(" ✓ all valid, with skin mesh") |
|
|
| for d in (ADIR,CDIR): |
| parts=[f for f in os.listdir(d) if f.endswith(".part")] |
| if parts: bad(".part leftovers in %s: %s"%(d,parts)) |
|
|
| print("=== 3. JSON COMPLETENESS ===") |
| P=json.load(open(os.path.join(ROOT,"animation_prompts.json"))) |
| F=json.load(open(os.path.join(ROOT,"animation_frames.json"))) |
| C=json.load(open(os.path.join(ROOT,"characters.json"))) |
| af={f for f in os.listdir(ADIR) if f.endswith(".fbx")} |
| cf={f for f in os.listdir(CDIR) if f.endswith(".fbx")} |
| def cmp(n,keys,files): |
| m=files-set(keys); x=set(keys)-files |
| if m: bad("%s missing %d: %s"%(n,len(m),list(m)[:5])) |
| if x: bad("%s extra %d: %s"%(n,len(x),list(x)[:5])) |
| if not m and not x: print(" ✓ %s == %d files"%(n,len(files))) |
| cmp("animation_prompts.json",P,af); cmp("animation_frames.json",F,af); cmp("characters.json",C,cf) |
|
|
| print("=== 4. JSON CORRECTNESS ===") |
| bp=[k for k,v in P.items() if not v.get("prompt") or not v.get("motion_id")] |
| if bp: bad("%d prompts missing prompt/id"%len(bp)) |
| else: print(" ✓ all prompts non-empty + motion_id") |
| mm=[(k,F[k],a["frames"].get(k)) for k in F if a["frames"].get(k)!=F[k]] |
| if mm: bad("%d frame values != reparsed: %s"%(len(mm),mm[:5])) |
| else: print(" ✓ all frame values == parsed FBX keyframes") |
| ids=[v["motion_id"] for v in P.values()] |
| print(" motion_ids: %d unique (%d dup)"%(len(set(ids)),len(ids)-len(set(ids)))) |
|
|
| if tokfile: |
| print("=== 5. API CROSS-CHECK (sample 40) ===") |
| import requests, mixamo_download as M |
| tok=open(tokfile).read().strip(); s=requests.Session(); s.headers.update(M.headers(tok)) |
| ok=0; bx=[] |
| for fn in random.sample(list(P),min(40,len(P))): |
| try: |
| det=M.get(s,"https://www.mixamo.com/api/v1/products/%s"%P[fn]["motion_id"],params={"character_id":M.Y_BOT}) |
| if det.get("name")==P[fn]["prompt"]: ok+=1 |
| else: bx.append((fn,det.get("name"),P[fn]["prompt"])) |
| except Exception as e: bx.append((fn,"err",str(e)[:30])) |
| time.sleep(0.15) |
| print(" prompt-name match: %d/40"%ok) |
| for b in bx[:8]: print(" ",b) |
| if ok==40: print(" ✓ sampled API cross-check clean") |
|
|
| print("\n===== SUMMARY: animation %d | character %d | PROBLEMS %d ====="%(a["count"],c["count"],len(problems))) |
| print("✓✓ ALL CHECKS PASSED" if not problems else "SEE PROBLEMS ABOVE") |
|
|