AutoModelForImageClassification
_BaseAutoClassAutoModelForImageClassification()Auto-dispatching wrapper that loads a registered image classifier.
The Auto* family lets you write framework-agnostic code that picks the right model at runtime — given a model name string, Lucid looks up the registry, verifies the model's declared task matches, and returns the concrete subclass with weights loaded.
Notes
Each registered model declares a class-level
_task: ClassVar[str]. This Auto class restricts lookups to
entries tagged "image-classification" and raises
ValueError on mismatch — preventing accidental loads of a
detection backbone or a language model as a classifier.
The returned object is a concrete subclass such as
ResNetForImageClassification or ViTForImageClassification;
its forward(images) returns an ImageClassificationOutput
with logits of shape (B, num_classes).
Examples
>>> from lucid.models import AutoModelForImageClassification
>>> model = AutoModelForImageClassification.from_pretrained("resnet_50")
>>> type(model).__name__
'ResNetForImageClassification'
>>> import lucid
>>> out = model(lucid.randn(1, 3, 224, 224))
>>> out.logits.shape
(1, 1000)