_images/lightly_train_light.svg _images/lightly_train_dark.svg

Build better computer vision models faster with self-supervised pre-training

LightlyTrain leverages self-supervised learning (SSL) and distillation from foundation models to train computer vision models on large datasets without labels. It provides simple Python, Command Line, and Docker interfaces to train models with popular pretraining methods such as SimCLR, DINO or distillation from DINOv2.

Why LightlyTrain?

  • 🚀 Higher accuracy – Pretrained models generalize better and achieve higher performance.

  • 💸 Cost efficiency – Make use of unlabeled data instead of letting it go to waste.

  • Faster convergence – Pretraining with LightlyTrain speeds up learning and reduces compute time.

  • 🖼️ Better image embeddings – Extract more meaningful features than with supervised models.

  • 🏗️ Stronger foundation – A great starting point for downstream tasks like:

    • Image classification

    • Object detection

    • Segmentation

  • 🔄 Improved domain adaptation – Self-supervised learning enables better adaptability to data shifts.

Lightly are the experts in computer vision pretraining and developed LightlyTrain to simplify model training for any task and dataset.

How It Works

Train a Model with SSL

import lightly_train

lightly_train.train(
    out="out/my_experiment",            # Output directory
    data="my_data_dir",                 # Directory with images
    model="torchvision/resnet50",       # Model to train
)

This will pretrain a Torchvision ResNet-50 model using images from my_data_dir and the DINO self-supervised learning method. All training logs, model exports, and checkpoints are saved to the output directory at out/my_experiment.

The final model is exported to out/my_experiment/exported_models/exported_last.pt in the default format of the used library. It can directly be used for fine-tuning. Follow the example to learn how to fine-tune a model.

After training is complete, you can either use the exported model for fine-tuning, or use the model to generate image embeddings.

Generate Image Embeddings

import lightly_train

lightly_train.embed(
    out="my_embeddings.pth",                                # Exported embeddings
    checkpoint="out/my_experiment/checkpoints/last.ckpt",   # LightlyTrain checkpoint
    data="my_data_dir",                                     # Directory with images
)

You can now use the generated embeddings for clustering, retrieval, or visualization tasks.

The quick start guide shows in more detail how to install and use LightlyTrain.

Features

Supported Models

Torchvision

  • ResNet

  • ConvNext

TIMM

  • All models

Ultralytics

  • YOLOv5

  • YOLOv6

  • YOLOv8

  • YOLO11

  • YOLO12

RT-DETR

  • RT-DETR

YOLOv12

  • YOLOv12

SuperGradients

  • PP-LiteSeg

  • SSD

  • YOLO-NAS

See supported models for a detailed list of all supported models.

Contact us if you need support for additional models or libraries.

Supported SSL Methods

  • DINO

  • DenseCL (experimental)

  • SimCLR

See methods for details.

License

LightlyTrain is available under an AGPL-3.0 and a commercial license. Please contact us at info@lightly.ai for more information.

Contact

Email | Website | Discord