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 and Holocron 0.2.2.dev0. The stable PyPI release is 0.2.1, and some APIs differ. See the installation options.

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 @ git+https://github.com/frgfm/holocron.git"

For stable 0.2.1 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.DEFAULT.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

Published checkpoints and metrics cover Imagenette, plus selected ReXNet ImageNet-1K variants.

Semantic segmentation — unbenchmarked

Object detection — experimental