Holocron: a Deep Learning toolbox for PyTorch¶
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:
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.
- TridentNet from "Scale-Aware Trident Networks for Object Detection"
- SKNet from "Selective Kernel Networks"
- PyConvResNet from "Pyramidal Convolution: Rethinking Convolutional Neural Networks for Visual Recognition"
- ReXNet from "ReXNet: Diminishing Representational Bottleneck on Convolutional Neural Network"
- RepVGG from "RepVGG: Making VGG-style ConvNets Great Again"
Semantic segmentation — unbenchmarked¶
- U-Net from "U-Net: Convolutional Networks for Biomedical Image Segmentation"
- U-Net++ from "UNet++: Redesigning Skip Connections to Exploit Multiscale Features in Image Segmentation"
- UNet3+ from "UNet 3+: A Full-Scale Connected UNet For Medical Image Segmentation"