Download src/converter/checkpoint_intake.py from Arm/Arm-Runtime-for-YOLO26-on-Raspberry-Pi-5: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/Arm/Arm-Runtime-for-YOLO26-on-Raspberry-Pi-5/resolve/main/src/converter/checkpoint_intake.py
- Command line
-
hf download hf://Arm/Arm-Runtime-for-YOLO26-on-Raspberry-Pi-5/src/converter/checkpoint_intake.py
-
curl -L -o checkpoint_intake.py https://huggingface.co/Arm/Arm-Runtime-for-YOLO26-on-Raspberry-Pi-5/resolve/main/src/converter/checkpoint_intake.py
1.42 kB
| #!/usr/bin/env python3 | |
| """Read a checkpoint and expose only validated YOLO26n model facts.""" | |
| from __future__ import annotations | |
| from pathlib import Path | |
| from .checkpoint_decoder import DecodedModule, decode_checkpoint_archive | |
| from .converter_io import RejectedInput | |
| from .model_contract import ValidatedYolo26n | |
| from .model_validation import validate_yolo26n_model | |
| def read_checkpoint(path: Path) -> bytes: | |
| """Read the checkpoint once so validation and export use identical bytes.""" | |
| return path.read_bytes() | |
| def _read_model_from_decoded_checkpoint(decoded: object) -> DecodedModule: | |
| """End the untyped pickle boundary by extracting its one required field.""" | |
| if not isinstance(decoded, dict): | |
| raise RejectedInput( | |
| "checkpoint root must be a mapping containing a YOLO26n model; " | |
| f"received {type(decoded).__name__}" | |
| ) | |
| model = decoded.get("model") | |
| if not isinstance(model, DecodedModule): | |
| raise RejectedInput( | |
| "checkpoint model must be ultralytics.nn.tasks.DetectionModel; " | |
| f"received {type(model).__name__!r}" | |
| ) | |
| return model | |
| def decode_checkpoint(checkpoint: bytes) -> ValidatedYolo26n: | |
| """Decode a Torch archive into the complete model contract used by export.""" | |
| decoded = decode_checkpoint_archive(checkpoint) | |
| return validate_yolo26n_model(_read_model_from_decoded_checkpoint(decoded)) | |