Quickstartο
This guide will help you get started with AstroPT quickly.
Loading a pre-trained modelο
To load and run a pre-trained AstroPT model from Hugging Face π€, use the load_astropt function:
from astropt.model_utils import load_astropt
model, model_args = load_astropt(
repo_id="smith42/astropt_sparse",
path="astropt/p16k10",
weights_filename="ckpt.pt",
)
model = model.to("cuda") # Move to GPU if available
Available pre-trained modelsο
Below are some pre-trained models you can load with the code snippet above:
DESI Legacy Survey Model
Modalities: JPG galaxy imagery
AstroPT version: v1.0.0
Model weights: AstroPT
Dataset: Galaxies Dataset
Paper: arXiv:2405.14930
DESI Legacy Survey Model (v2.0)
Modalities: JPG galaxy imagery (cropped and zoomed)
AstroPT version: v2.0.4
Model weights: AstroPT v2.0
Dataset: Galaxies Dataset
Paper: arXiv:2405.14930
Euclid Model
Modalities: FITS VIS, NISP galaxy imagery and SED data
AstroPT version: v1.0.2
Model weights: AstroPT-Euclid
Dataset: Euclid Training Dataset
Paper: arXiv:2503.15312
Basic model usageο
Hereβs a simple example of how to use the model for inference:
import torch
from astropt.model_utils import load_astropt
# Load the model
model, model_args = load_astropt(
repo_id="smith42/astropt_sparse",
path="astropt/p16k10",
weights_filename="ckpt.pt",
)
model = model.to("cuda")
# Prepare your input data
# This is a simplified example - actual preprocessing depends on your data
input_data = preprocess_your_data(your_data)
# Convert to tensor and move to the same device as the model
input_tensor = torch.tensor(input_data).to("cuda")
# Run inference
with torch.no_grad():
output = model(input_tensor)
# Process the output
processed_output = process_output(output)