Download scripts/_static_consistency.py from LiYacheng/r4d-bench-qa: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/datasets/LiYacheng/r4d-bench-qa/resolve/main/scripts/_static_consistency.py
- Command line
-
hf download hf://datasets/LiYacheng/r4d-bench-qa/scripts/_static_consistency.py
-
curl -L -o _static_consistency.py https://huggingface.co/datasets/LiYacheng/r4d-bench-qa/resolve/main/scripts/_static_consistency.py
1.31 kB
| """Static-camera scenes: IoU of each frame's track mask vs the per-pixel majority mask.""" | |
| import sys | |
| from pathlib import Path | |
| import numpy as np | |
| ROOT = Path(__file__).resolve().parents[1] | |
| sys.path.insert(0, str(ROOT)) | |
| from scripts._rel_motion import masks | |
| NEU3D = ["cook_spinach", "cut_roasted_beef", "flame_salmon", "sear_steak", "coffee_martini", "flame_steak"] | |
| def main(): | |
| thr = float(sys.argv[1]) if len(sys.argv) > 1 else 0.85 | |
| for scene in NEU3D: | |
| ms = masks(scene) | |
| tracks = sorted({t for d in ms.values() for t in d}) | |
| print(f"#### {scene}") | |
| for t in tracks: | |
| fr = [f for f in sorted(ms) if t in ms[f]] | |
| stack = np.stack([ms[f][t] for f in fr]) | |
| maj = stack.mean(0) >= 0.5 | |
| ious = [] | |
| for f, m in zip(fr, stack): | |
| ious.append((f, (m & maj).sum() / max((m | maj).sum(), 1), m.sum() / max(maj.sum(), 1))) | |
| bad = [(f, i, a) for f, i, a in ious if i < thr] | |
| med = np.median([i for _, i, _ in ious]) | |
| if med > 0.8: | |
| tag = " ".join(f"f{f}(iou={i:.2f},area={a:.2f})" for f, i, a in bad) | |
| print(f" {t}: median IoU={med:.2f} {'OUTLIERS: ' + tag if bad else ''}") | |
| if __name__ == "__main__": | |
| main() | |