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.

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:

pip install pylocron

Check out the installation guide for more options

Quick start

Load a model and use it just like any PyTorch model:

from PIL import Image
from torchvision.transforms.v2 import Compose, ConvertImageDtype, Normalize, PILToTensor, Resize
from torchvision.transforms.v2.functional import InterpolationMode
from holocron.models.classification import repvgg_a0

# Load your model
model = repvgg_a0(pretrained=True).eval()

# Read your image
img = Image.open(path_to_an_image).convert("RGB")

# Preprocessing
config = model.default_cfg
transform = Compose([
    Resize(config['input_shape'][1:], interpolation=InterpolationMode.BILINEAR),
    PILToTensor(),
    ConvertImageDtype(torch.float32),
    Normalize(config['mean'], config['std'])
])

input_tensor = transform(img).unsqueeze(0)

# Inference
with torch.inference_mode():
    output = model(input_tensor)
print(config['classes'][output.squeeze(0).argmax().item()], output.squeeze(0).softmax(dim=0).max())

Model zoo

Image classification

Semantic segmentation

Object detection