Weights API¶
modern_yolonas.weights.load_pretrained(model, variant, strict=True, repo_id=HF_REPO_ID, revision=None)
¶
Download safetensors checkpoint from HF Hub and load into model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
A |
required |
variant
|
str
|
One of |
required |
strict
|
bool
|
Require exact key matching. |
True
|
repo_id
|
str
|
HF Hub repo (default :data: |
HF_REPO_ID
|
revision
|
str | None
|
Git ref (branch / tag / commit) of the repo. |
None
|
Returns:
| Type | Description |
|---|---|
Module
|
The model with loaded weights. |
Source code in src/modern_yolonas/weights.py
modern_yolonas.weights.remap_state_dict(raw_sd)
¶
Remap super-gradients state_dict keys to our module hierarchy.
Super-gradients wraps the model in CustomizableDetector with::
backbone → backbone.stem, backbone.stage1 … backbone.stage4, backbone.context_module
neck → neck.neck1 … neck.neck4
heads → heads.head1 … heads.head3
Our YoloNAS uses the same attribute names, so the only work is
stripping DDP/EMA prefixes.