Skip to content
data

WeightEntry

WeightEntry(url: str, sha256: str, num_classes: int, transforms: Transform, meta: dict[str, object] = dict(), key_map: dict[str, str] = dict(), requires_config: dict[str, object] = dict())

Immutable manifest describing one pretrained checkpoint.

A WeightEntry is the value held by each WeightsEnum member. It is everything the runtime needs to fetch, verify, and load a checkpoint — but nothing about the model architecture itself (that is fixed by the factory that consumes the entry).

Parameters

urlstr
Direct download URL of the model.safetensors blob. Lucid hosts these on the Hugging Face Hub under the lucid-dl org (.../resolve/main/<TAG>/model.safetensors) but no provider-specific knowledge is encoded here — any HTTPS URL works.
sha256str
Hex-encoded SHA-256 digest of the file at url. Verified after download and on every cache hit; a mismatch forces a re-download (the cached copy is presumed corrupt).
num_classesint
Number of output classes the checkpoint's head produces (e.g. 1000 for ImageNet-1k). Lets callers sanity-check the entry against a model's configured num_classes before loading.
transformsTransform
Preprocessing pipeline the weights were trained with — applied to inputs at inference time so resnet_18(pretrained=True) "just works". A lucid.utils.transforms transform (e.g. lucid.utils.transforms.ImageClassification).
metadict= dict()
Free-form provenance + metrics. Conventional keys: source (e.g. "reference_vision/ResNet18_Weights.IMAGENET1K_V1"), license, recipe, metrics (nested {dataset: {metric: value}}), num_params, gflops, file_size_mb. Rendered into the Hub config.json + model card by the conversion tool.
key_mapdict= dict()
Old-name → new-name renames applied to the checkpoint's keys before loading, for a converted checkpoint whose layout differs from the model's by naming alone. Empty for almost every entry. It exists because a head can be a bare Linear in one variant and a Sequential of [Dropout, Linear] in another: the dropout carries no parameters, so the two hold identical weights under different names, and a converter that flattened the head produces a checkpoint that is correct yet unloadable. Renaming is honest here in a way that shape-changing would not be — nothing about the tensors is reinterpreted. A rename whose source key is absent from the checkpoint is an error, not a silent no-op; a stale map would otherwise keep passing after the layout it patched had changed.
requires_configdict= dict()
Config fields this checkpoint was trained with, checked against the model before anything is downloaded. Empty for most entries; the ones that carry it earned it. A checkpoint is trained against one architecture, and the config that describes it is written somewhere else entirely — in a factory, beside a paper citation, by someone reading a reference implementation. When the two drift, what happens depends on whether the field touches a parameter. If it does, the load fails on a shape and the caller finds out. If it does not, the load is clean and the model computes a different function: the checkpoints for this zoo's SE-ResNet were trained with an activation the code did not apply, and CSPNet's with a different leaky slope and two cross-stages left linear. Nothing about either is visible to a shape check, and both were found by running the models against the implementation the weights came from — which is not a thing a load can do. Declaring the values is what turns that class of drift back into an error at the point it matters. It cannot cover everything: a constant in the model file rather than a field in the config has nothing to declare against, and CSPNet's leaky slope is still one of those.

Notes

Frozen (frozen=True) so entries can be shared by reference and used as enum.Enum values. Two members carrying the same WeightEntry instance collapse into an enum alias — this is how DEFAULT = IMAGENET1K_V1 works (see WeightsEnum).

Used by 2