Download environment/training-source/source-snapshot/tools/make_correctness_frame.py from mad-bot/dinovision: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/mad-bot/dinovision/resolve/main/environment/training-source/source-snapshot/tools/make_correctness_frame.py
- Command line
-
hf download hf://mad-bot/dinovision/environment/training-source/source-snapshot/tools/make_correctness_frame.py
-
curl -L -o make_correctness_frame.py https://huggingface.co/mad-bot/dinovision/resolve/main/environment/training-source/source-snapshot/tools/make_correctness_frame.py
1.3 kB
| #!/usr/bin/env python3 | |
| """Generate the deterministic RGB8 frame used for host/device parity.""" | |
| from __future__ import annotations | |
| import argparse | |
| import hashlib | |
| from pathlib import Path | |
| def main() -> None: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--output", required=True, type=Path) | |
| parser.add_argument("--size", type=int, default=224) | |
| args = parser.parse_args() | |
| if args.size <= 1 or args.size % 16: | |
| raise SystemExit("--size must be greater than one and divisible by 16") | |
| pixels = bytearray() | |
| center = (args.size - 1) / 2.0 | |
| radius_squared = (args.size * 0.28) ** 2 | |
| for y in range(args.size): | |
| for x in range(args.size): | |
| red = round(255 * x / (args.size - 1)) | |
| green = round(255 * y / (args.size - 1)) | |
| checker = 48 if ((x // 16) ^ (y // 16)) & 1 else 208 | |
| in_circle = (x - center) ** 2 + (y - center) ** 2 < radius_squared | |
| blue = 255 - checker if in_circle else checker | |
| pixels.extend((red, green, blue)) | |
| args.output.parent.mkdir(parents=True, exist_ok=True) | |
| args.output.write_bytes(pixels) | |
| digest = hashlib.sha256(pixels).hexdigest() | |
| print(f"wrote {args.output}: {len(pixels)} bytes, SHA-256 {digest}") | |
| if __name__ == "__main__": | |
| main() | |