LightlyTrain:更优的视觉模型,更快的训练速度——无需标注数据
LightlyTrain: Better Vision Models, Faster – No Labels Needed

原始链接: https://github.com/lightly-ai/lightly-train

LightlyTrain 通过利用未标注数据进行自监督预训练,简化了计算机视觉模型的开发流程。这降低了标注成本,并加快了模型部署速度,尤其适用于视频分析、医疗保健和制造等特定领域的应用。它兼容各种架构和任务(检测、分类、分割),并且可以扩展到数百万张图像,支持从单GPU到多节点的各种设置。 它无需手动实现,而是与PyTorch等流行库集成,自动处理层预训练和模型导出等关键方面。 当标注数据稀少、特定领域的数据与标准数据集差异显著、策略限制使用外部模型或使用缺乏预训练检查点的自定义架构时,LightlyTrain 尤其有效。它建议使用远多于标注数据的未标注数据以获得最佳结果。 LightlyTrain 提供 AGPL-3.0 和商业许可证,满足开源和专有需求,使用户能够最大限度地利用其未标注数据的价值。

Lightly AI发布了LightlyTrain,一个开源的Python包,用于自监督学习(SSL)。它能够在未标记的数据上预训练计算机视觉模型,从而提高在标记数据有限的特定领域任务中的性能。与在通用数据集上预训练的标准模型不同,LightlyTrain会在微调之前使模型适应特定的视觉领域(例如,医疗、农业、制造业)。 其主要特点包括:无需标签的预训练、比从零开始训练更好的性能、领域自适应、支持流行的模型(YOLO、RT-DETR、ResNet、ViTs)以及可扩展性。在COCO、BDD100K、DeepLesion和DeepWeeds上的基准测试显示,其性能优于基线。例如,在COCO数据集上使用10%的标签,使用LightlyTrain预训练的YOLOv8-s模型的mAP比ImageNet权重提高了14%。该软件包采用AGPL-3.0许可证,并与Ultralytics和Torchvision等框架集成。对于需要不同许可条款的企业,可以提供商业许可证。

原文
LightlyTrain Logo

Google Colab Python OS Docker Documentation Discord

Train Better Models, Faster - No Labels Needed

LightlyTrain brings self-supervised pretraining to real-world computer vision pipelines, using your unlabeled data to reduce labeling costs and speed up model deployment. Leveraging the state-of-the-art from research, it pretrains your model on your unlabeled, domain-specific data, significantly reducing the amount of labeling needed to reach a high model performance.

This allows you to focus on new features and domains instead of managing your labeling cycles. LightlyTrain is designed for simple integration into existing training pipelines and supports a wide range of model architectures and use-cases out of the box.

  • 💸 No Labels Required: Speed up development by pretraining models on your unlabeled image and video data.
  • 🔄 Domain Adaptation: Improve models by pretraining on your domain-specific data (e.g. video analytics, agriculture, automotive, healthcare, manufacturing, retail, and more).
  • 🏗️ Model & Task Agnostic: Compatible with any architecture and task, including detection, classification, and segmentation.
  • 🚀 Industrial-Scale Support: LightlyTrain scales from thousands to millions of images. Supports on-prem, cloud, single, and multi-GPU setups.

Benchmark Results

On COCO, YOLOv8-s models pretrained with LightlyTrain achieve high performance across all tested label fractions. These improvements hold for other architectures like YOLOv11, RT-DETR, and Faster R-CNN. See our announcement post for more details.

Install LightlyTrain:

pip install lightly-train

Then start pretraining with:

import lightly_train

if __name__ == "__main__":
  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 unlabeled images from my_data_dir. 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.

Finally, load the pretrained model and fine-tune it using your existing training pipeline:

import torch
from torchvision import models

# Load the pretrained model
model = models.resnet50()
model.load_state_dict(torch.load("out/my_experiment/exported_models/exported_last.pt"))

# Fine-tune the model with your existing training pipeline
...

See also:

  • Fine-Tune Example: Looking for a full fine-tuning example? Head over to the Quick Start!

  • Embedding Example: Want to use your pretrained model to generate image embeddings instead? Check out the embed guide!

  • More Tutorials: Want to get more hands-on with LightlyTrain? Check out our Tutorials for more examples!

Framework Supported Models Docs
Torchvision ResNet, ConvNext 🔗
TIMM All models 🔗
Ultralytics YOLOv5, YOLOv6, YOLOv8, YOLO11, YOLO12 🔗
RT-DETR RT-DETR 🔗
RF-DETR RF-DETR 🔗
YOLOv12 YOLOv12 🔗
SuperGradients PP-LiteSeg, SSD, YOLO-NAS 🔗
Custom Models Any PyTorch model 🔗

For an overview of all supported models and usage instructions, see the full model docs.

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

Supported Training Methods

See the full methods docs for details.

Who is LightlyTrain for?

LightlyTrain is designed for engineers and teams who want to use their unlabeled data to its full potential. It is ideal if any of the following applies to you:

  • You want to speedup model development cycles
  • You have limited labeled data but abundant unlabeled data
  • You have slow and expensive labeling processes
  • You want to build your own foundation model
  • You work with domain-specific datasets (video analytics, robotics, medical, agriculture, etc.)
  • You cannot use public pretrained models
  • No pretrained models are available for your specific architecture
  • You want to leverage the latest research in self-supervised learning and distillation
How much data do I need?

We recommend a minimum of several thousand unlabeled images for training with LightlyTrain and 100+ labeled images for fine-tuning afterwards.

For best results:

  • Use at least 5x more unlabeled than labeled data
  • Even a 2x ratio of unlabeled to labeled data yields strong improvements
  • Larger datasets (>100,000 images) benefit from pretraining up to 3,000 epochs
  • Smaller datasets (<100,000 images) benefit from longer pretraining of up to 10,000 epochs

The unlabeled dataset must always be treated like a training split—never include validation images in pretraining to avoid data leakage.

What's the difference between LightlyTrain and other self-supervised learning implementations?

LightlyTrain offers several advantages:

  • User-friendly: You don't need to be an SSL expert - focus on training your model instead of implementation details.
  • Works with various model architectures: Integrates directly with different libraries such as Torchvision, Ultralytics, etc.
  • Handles complexity: Manages scaling from single GPU to multi-GPU training and optimizes hyperparameters.
  • Seamless workflow: Automatically pretrains the correct layers and exports models in the right format for fine-tuning.
Why should I use LightlyTrain instead of other already pretrained models?

LightlyTrain is most beneficial when:

  • Working with domain-specific data: When your data has a very different distribution from standard datasets (medical images, industrial data, etc.)
  • Facing policy or license restrictions: When you can't use models pretrained on datasets with unclear licensing
  • Having limited labeled data: When you have access to a lot of unlabeled data but few labeled examples
  • Using custom architectures: When no pretrained checkpoints are available for your model

LightlyTrain is complementary to existing pretrained models and can start from either random weights or existing pretrained weights.

Check our complete FAQ for more information.

LightlyTrain offers flexible licensing options to suit your specific needs:

  • AGPL-3.0 License: Perfect for open-source projects, academic research, and community contributions. Share your innovations with the world while benefiting from community improvements.

  • Commercial License: Ideal for businesses and organizations that need proprietary development freedom. Enjoy all the benefits of LightlyTrain while keeping your code and models private.

We're committed to supporting both open-source and commercial users. Contact us to discuss the best licensing option for your project!

Website
Discord
GitHub
X
LinkedIn

联系我们 contact @ memedata.com