Skip to content
module

weights

9 members
lucid.weights

lucid.weights — pretrained-weight system for the model zoo.

A standalone package (sibling to lucid.models) that provides the infrastructure for pretrained checkpoints: the tagged-variant enum base, hub download + SHA verification, loading, and a discovery registry. Preprocessing lives in lucid.utils.transforms; a checkpoint's WeightEntry carries one of those transforms.

It deliberately contains no architecture-specific weight declarations. Each model family declares its own checkpoints in a _weights.py module inside the model package (e.g. lucid.models.vision.resnet._weights.ResNet18Weights), importing the primitives below. This keeps lucid.weights a pure porting substrate and the dependency one-directional (models → weights, never the reverse).

Notes

Each architecture declares a WeightsEnum (e.g. ResNet18Weights) whose members are WeightEntry manifests — one per tagged checkpoint (IMAGENET1K_V1, …) plus a DEFAULT alias. This mirrors the reference_vision Weights enum so call sites are familiar:

import lucid.models as models
import lucid.weights as weights

# default tag
model = models.resnet_18(pretrained=True)

# explicit tag — enum or string
from lucid.models.vision.resnet import ResNet18Weights
model = models.resnet_18_cls(weights=ResNet18Weights.IMAGENET1K_V1)
model = models.resnet_18_cls(pretrained="IMAGENET1K_V1")

# discover + preprocess (after the model package is imported)
weights.list_pretrained("resnet_18")        # ['IMAGENET1K_V1']
w = weights.get_weight("ResNet18Weights.IMAGENET1K_V1")
x = w.transforms()(image)

The package depends only on lucid.serialization (for SafeTensors loading); model factories depend on it, never the reverse, so there is no circular import. Crucially, WeightEntry carries no model config — named factories already pin their own.

Checkpoints are hosted on the Hugging Face Hub under the lucid-dl org, converted offline from reference_vision / timm / transformers sources.

Attributes

HUB_BASEstr
Hugging Face Hub URL root for every Lucid-hosted checkpoint. Each per-family _weights.py imports this and composes its repo URL as f"{HUB_BASE}/<family-slug>/resolve/main/<TAG>/model.safetensors", so the org name lives in exactly one place (e.g. if Lucid ever moves off the lucid-dl org, only this constant changes).

Classes

Functions