#!/usr/bin/env python3 """FINAL exhaustive audit of the whole mixamo/ dataset. Checks every file in animation/, character/, character_refined/, all JSON indexes, content-duplicate detection, and functional bone-name compatibility.""" import os, re, sys, json, hashlib HERE=os.path.dirname(os.path.abspath(__file__)); sys.path.insert(0,HERE) from fbx_frames import parse as fp from fbx_bones import bones as real_bones ROOT=os.path.dirname(HERE) A=os.path.join(ROOT,"animation"); C=os.path.join(ROOT,"character"); R=os.path.join(ROOT,"character_refined") MAGIC=b"Kaydara FBX Binary \x00" prob=[]; W=lambda m:(prob.append(m),print(" ✗",m)) BONE=re.compile(rb'mixamorig:([A-Za-z0-9_]+)') CORRUPT=re.compile(rb'mixamorig[0-9]+:') def md5(p, limit=None): h=hashlib.md5() with open(p,'rb') as f: while True: b=f.read(1<<20) if not b: break h.update(b) return h.hexdigest() def audit(d,label,need_mesh,need_anim): files=sorted(f for f in os.listdir(d) if f.endswith(".fbx")) print("=== %s (%d files) ==="%(label,len(files))) bad=[];tiny=[];norig=[];noanim=[];nomesh=[];corrupt=[];vers={};frames={};bones={};hashes={} junk=[f for f in os.listdir(d) if not f.endswith(".fbx")] if junk: W("%s has non-fbx files: %s"%(label,junk[:5])) for i,f in enumerate(files,1): p=os.path.join(d,f); sz=os.path.getsize(p) if sz==0: bad.append((f,"zero bytes")); continue with open(p,'rb') as fh: head=fh.read(32) if not head.startswith(MAGIC): bad.append((f,"bad magic")); continue try: vv=fp(p); vers[vv["version"]]=vers.get(vv["version"],0)+1; frames[f]=vv["keys_max"] except Exception as e: bad.append((f,"parse:"+str(e)[:30])); continue b=open(p,'rb').read() if sz < (10000 if need_mesh else 2000): tiny.append((f,sz)) if b"LimbNode" not in b: norig.append(f) if need_anim and b"KeyTime" not in b: noanim.append(f) if need_mesh and b.count(b"Vertices")<1: nomesh.append(f) if CORRUPT.search(b): corrupt.append(f) try: bones[f]=real_bones(p) except Exception: bones[f]=set() hashes.setdefault(md5(p),[]).append(f) if i%600==0: print(" ...%d/%d"%(i,len(files)),flush=True) for lbl,lst in [("invalid",bad),("suspiciously small",tiny),("no skeleton",norig), ("no animation curves",noanim),("no skin mesh",nomesh), ("corrupted mixamorig:",corrupt)]: if lst: if lbl.startswith("corrupted") and "original" in label: print(" i %s: %d %s (EXPECTED - originals kept unmodified; fixes live in character_refined/)"%(label,len(lst),lbl)) else: W("%s: %d %s -> %s"%(label,len(lst),lbl,lst[:4])) if not any([bad,tiny,norig,noanim,nomesh]) and (not corrupt or "original" in label): print(" ✓ all %d valid, non-truncated%s%s, no corrupt namespaces"%( len(files)," + animated" if need_anim else ""," + skinned" if need_mesh else "")) print(" FBX versions:",dict(sorted(vers.items()))) dups={h:v for h,v in hashes.items() if len(v)>1} if dups: print(" byte-identical duplicate groups: %d (e.g. %s)"%(len(dups),list(dups.values())[:2])) else: print(" ✓ no byte-identical duplicates") return files,frames,bones,dups af,afr,abones,adup = audit(A,"animation",False,True) cf,_,cbones,_ = audit(C,"character (original)",True,False) rf,_,rbones,_ = audit(R,"character_refined",True,False) print("=== JSON indexes ===") P=json.load(open(os.path.join(ROOT,"animation_prompts.json"))) F=json.load(open(os.path.join(ROOT,"animation_frames.json"))) CH=json.load(open(os.path.join(ROOT,"characters.json"))) if set(P)!=set(af): W("prompts keys != animation files") if set(F)!=set(af): W("frames keys != animation files") if set(CH)!=set(cf): W("characters keys != character files") if set(P)==set(F)==set(af) and set(CH)==set(cf): print(" ✓ prompts=%d frames=%d == %d anim files; characters=%d == %d files"%(len(P),len(F),len(af),len(CH),len(cf))) mm=[(k,F[k],afr.get(k)) for k in F if afr.get(k)!=F[k]] if mm: W("%d frame values mismatch reparse: %s"%(len(mm),mm[:4])) else: print(" ✓ all %d frame values == freshly parsed keyframes"%len(F)) badv=[k for k,v in F.items() if not isinstance(v,int) or v<1] if badv: W("%d bad frame values"%len(badv)) badp=[k for k,v in P.items() if not v.get("prompt") or not re.match(r'^[0-9a-f-]{20,}$',str(v.get("motion_id",'')))] if badp: W("%d malformed prompts: %s"%(len(badp),badp[:4])) else: print(" ✓ all prompts well-formed") ids=[v["motion_id"] for v in P.values()] if len(ids)!=len(set(ids)): W("%d duplicate motion_ids"%(len(ids)-len(set(ids)))) else: print(" ✓ %d motion_ids unique"%len(ids)) uu=[v["uuid"] for v in CH.values()] if len(uu)!=len(set(uu)): W("%d duplicate character uuids"%(len(uu)-len(set(uu)))) else: print(" ✓ %d character uuids unique"%len(uu)) print("=== FUNCTIONAL: can animations drive the characters? ===") anim_union=set() for s in abones.values(): anim_union|=s print(" distinct animation bone names: %d"%len(anim_union)) std=[f for f,s in rbones.items() if s] nonstd=[f for f,s in rbones.items() if not s] full=[f for f in std if anim_union<=rbones[f]] partial=[(f,len(anim_union-rbones[f])) for f in std if not (anim_union<=rbones[f])] print(" refined chars with mixamorig rig : %d"%len(std)) print(" ├─ covering ALL animation bones : %d ✓ retargetable"%len(full)) print(" └─ missing some bones : %d %s"%(len(partial),partial[:6])) print(" refined chars with non-mixamorig rig : %d %s"%(len(nonstd),nonstd)) # compare: how many ORIGINAL characters were retargetable (before the fix) ostd=[f for f,s in cbones.items() if s] ofull=[f for f in ostd if anim_union<=cbones[f]] print(" (before fix: %d/%d characters had a usable mixamorig rig)"%(len(ofull),len(cf))) print("\n===== FINAL AUDIT: PROBLEMS = %d ====="%len(prob)) print("✓✓ DATASET FULLY VERIFIED" if not prob else "SEE PROBLEMS ABOVE")