Documentation Index
Fetch the complete documentation index at: https://mintlify.com/mwalmsley/zoobot/llms.txt
Use this file to discover all available pages before exploring further.
FinetuneableZoobotAbstract is the parent class shared by all three Zoobot finetuning classes. It defines how to load a pretrained encoder, configure the AdamW optimizer with optional layer decay, and run training and validation steps via PyTorch Lightning. You cannot instantiate this class directly — use FinetuneableZoobotClassifier, FinetuneableZoobotRegressor, or FinetuneableZoobotTree instead.
Loading a Pretrained Encoder
AnyFinetuneableZoobot model can be loaded in one of three ways:
- HuggingFace Hub (Recommended)
- In-Memory Encoder
- Local Checkpoint
Constructor Parameters
These parameters are accepted by all threeFinetuneableZoobot child classes (plus their own task-specific args).
HuggingFace Hub model name, e.g.
'hf_hub:mwalmsley/zoobot-encoder-convnext_nano'. Recommended for loading published pretrained models. Mutually exclusive with encoder and zoobot_checkpoint_loc.A PyTorch model already loaded in memory with a
.forward() method. Mutually exclusive with name and zoobot_checkpoint_loc.Path to a saved
ZoobotTree or FinetuneableZoobotTree Lightning checkpoint from which the encoder is extracted. Mutually exclusive with name and encoder.Controls which parameters are trained.
'full' trains all parameters (encoder + head). 'head_only' freezes the encoder and only trains the new head (linear probing / transfer learning).Learning rate decay applied per encoder layer block going deeper from the head. A value of
0.75 means each successive block has 0.75x the learning rate of the block above it. Set to 1.0 for no decay. Only applies when training_mode='full'.L2 regularization penalty applied via AdamW. Higher values penalize large weights more strongly to prevent overfitting.
Base learning rate for the AdamW optimizer. The head always uses this rate; encoder layers use
learning_rate * layer_decay ** i.Probability of dropout applied to encoder output features before the final linear head layer. Acts as regularization.
Arguments for an optional
timm learning rate scheduler. Example: {'name': 'cosine', 'warmup_epochs': 5, 'max_epochs': 100}. Defaults to None (no scheduler).Additional keyword arguments passed to
timm.create_model() when loading an encoder by name. For example, {'drop_path_rate': 0.1}.If
True, adds {'in_chans': 1} to timm_kwargs to convert the encoder to single-channel input. Use when loading FITS images or other single-channel data.Whether to display a progress bar during training.
Upload example validation images to Weights & Biases. Helpful for debugging data loading but may slow training.
Random seed passed to
lightning.seed_everything().Methods
configure_optimizers()
Sets up the AdamW optimizer with layer-wise learning rate decay and an optional timm scheduler. When training_mode='head_only', the encoder is frozen and only self.head parameters are optimized.
load_from_name(name, **kwargs) (classmethod)
Download and load a previously finetuned model stored on HuggingFace Hub. The name argument is the HuggingFace repo ID. Internally calls hf_hub_download and then load_from_checkpoint.
forward(x)
Passes x through the encoder then the head. Returns raw head outputs (logits for classifiers, raw scalars for regressors).
Subclassing for Custom Tasks
You can subclassFinetuneableZoobotAbstract to finetune Zoobot on tasks beyond classification, regression, and vote counts. At minimum you must set self.head, self.loss, and implement batch_to_supervised_tuple.