Skip to content

Holocron: a Deep Learning toolbox for PyTorch

Holocron logo

Holocron is meant to bridge the gap between PyTorch and latest research papers. It brings training components that are not available yet in PyTorch with a similar interface.

Development documentation

These pages follow the main branch. The latest PyPI release may not include recent changes.

This project is meant for:

  • ⚡ speed: architectures in this repo are picked for both pure performances and minimal latency
  • 👩‍🔬 research: train your models easily to SOTA standards

Installation

Create and activate a virtual environment and then install Holocron:

uv pip install pylocron

For development and system-wide options, see the installation guide.

Quick start

Load a checkpoint and use its preprocessing and category metadata:

import torch
from PIL import Image
from torchvision.transforms.v2 import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
from holocron.models.classification import ResNet18_Checkpoint, resnet18

checkpoint = ResNet18_Checkpoint.IMAGENETTE.value
model = resnet18(checkpoint=checkpoint).eval()

image = Image.open(path_to_an_image).convert("RGB")
preprocessing = checkpoint.pre_processing

transform = Compose([
    Resize(preprocessing.input_shape[1:], interpolation=preprocessing.interpolation),
    PILToTensor(),
    ConvertImageDtype(torch.float32),
    Normalize(preprocessing.mean, preprocessing.std),
])

input_tensor = transform(image).unsqueeze(0)

with torch.inference_mode():
    probabilities = model(input_tensor).squeeze(0).softmax(dim=0)

class_idx = probabilities.argmax().item()
label = checkpoint.meta.categories[class_idx]
confidence = probabilities[class_idx].item()
print(label, confidence)

To adapt this checkpoint to your own classes, follow the classification and transfer-learning guide.

Model zoo

Holocron implements all three tasks below, but they do not have the same level of checkpoint and benchmark coverage. See the capability and maturity matrix before choosing a model.

Image classification — validated checkpoints

See the available checkpoints for datasets, metrics, weight compatibility and loading instructions. Most classification checkpoints target Imagenette (10 classes); selected ReXNet variants also provide ImageNet-1K weights (1,000 classes).

Semantic segmentation — unbenchmarked

Object detection — experimental