| """ |
| Quick check: how many clips actually contain contact (nonzero) frames? |
| If most clips are all-zero, the VAE will collapse to predicting 0. |
| |
| Usage: |
| python check_clip_activity.py --clips ... --stats ... --source_root ... --modality contact --n 200 |
| """ |
| import argparse, sys, os |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
| from physical_dataset import PhysicalClipDataset |
| import numpy as np |
|
|
| ap = argparse.ArgumentParser() |
| ap.add_argument("--clips", required=True) |
| ap.add_argument("--stats", required=True) |
| ap.add_argument("--source_root", required=True) |
| ap.add_argument("--modality", default="contact") |
| ap.add_argument("--n", type=int, default=200, help="how many clips to scan") |
| args = ap.parse_args() |
|
|
| ds = PhysicalClipDataset(args.clips, args.stats, args.source_root, args.modality) |
| n = min(args.n, len(ds)) |
| print(f"scanning {n}/{len(ds)} clips...") |
|
|
| all_zero = 0 |
| active_fracs = [] |
| contact_frame_counts = [] |
| for i in range(n): |
| item = ds[i] |
| m = item["active_mask"] |
| af = float(m.mean()) |
| active_fracs.append(af) |
| if af == 0.0: |
| all_zero += 1 |
| |
| per_frame = m[0].reshape(m.shape[1], -1).sum(1) |
| contact_frame_counts.append(int((per_frame > 0).sum())) |
|
|
| active_fracs = np.array(active_fracs) |
| cfc = np.array(contact_frame_counts) |
| print(f"\nall-zero clips: {all_zero}/{n} ({100*all_zero/n:.1f}%)") |
| print(f"active frac: mean={active_fracs.mean():.4f} max={active_fracs.max():.4f}") |
| print(f"contact frames per clip (of 17): mean={cfc.mean():.1f} " |
| f"min={cfc.min()} max={cfc.max()}") |
| print(f"clips with >=1 contact frame: {(cfc>0).sum()}/{n} ({100*(cfc>0).sum()/n:.1f}%)") |
| print(f"clips with >=8 contact frames: {(cfc>=8).sum()}/{n}") |