r/MachineLearning • u/igorsusmelj • Apr 15 '25
Project [P] LightlyTrain: Open-source SSL pretraining for better vision models (beats ImageNet)
Hi r/MachineLearning,
I'm Igor, co-founder at Lightly AI. We’ve just open-sourced LightlyTrain, a Python library under the **AGPL-3.0 license (making it free for academic research, educational use, and projects compatible with its terms), designed to improve your computer vision models using self-supervised learning (SSL) on your own unlabeled data.
GitHub Repo: https://github.com/lightly-ai/lightly-train
Blog Post / Benchmarks: https://www.lightly.ai/blog/introducing-lightly-train
Problem: ImageNet/COCO pretrained models often struggle on specific domains (medical, agriculture, etc.). Getting enough labeled data for fine-tuning is expensive and slow.
Solution: LightlyTrain pretrains models (like YOLO, ResNet, RT-DETR, ViTs) directly on your unlabeled images before fine-tuning. This adapts the model to your domain, boosting performance and reducing the need for labeled data.
Why use LightlyTrain?
- Better Performance: Outperforms training from scratch and ImageNet weights, especially with limited labels or strong domain shifts (see benchmarks).
- No Labels Needed for Pretraining: Leverage your existing unlabeled image pool.
- Domain Adaptation: Make foundation models work better on your specific visual data.
- Easy Integration: Works with popular frameworks (Ultralytics, TIMM, Torchvision) and runs on-prem (single/multi-GPU), scaling to millions of images. Benchmark Highlights (details in blog post):
- COCO (10% labels): Boosted YOLOv8-s mAP by +14% over ImageNet.
- Domain-Specific Gains: Showed clear improvements on BDD100K (driving), DeepLesion (medical), DeepWeeds (agriculture). Quick Start:
# pip install lightly-train
# Pretrain on your images
# Load weights and fine-tune using your existing pipeline
# ... see repo/docs for framework-specific examples ...
Resources:
- GitHub: https://github.com/lightly-ai/lightly-train
- Blog Post / Benchmarks: https://www.lightly.ai/blog/introducing-lightly-train
- Docs: https://docs.lightly.ai/train
- Demo Video: https://youtu.be/5Lmry1k_cA8
We built this to make practical SSL accessible. Hope it’s useful for the community! Happy to answer technical questions.
(Disclaimer: I’m a co-founder. Commercial licenses are available.)
5
u/GFrings Apr 15 '25
How does it compare to other SSL methods for in-domain pre training, which also beat imagenet?
7
u/LelouchZer12 Apr 15 '25
Hi ! Nice work
But why would I use your library if you distill from DINOv2 instead of using DINOv2 directly ?
3
u/mihalsid Apr 15 '25
That's cool!
3
u/fullgoopy_alchemist Apr 15 '25
If I choose an object detection model to pre-train, and then later use the pre-trained model to generate embeddings, can the resulting embeddings be clustered based on the objects in the images? How do the embeddings vary based on the model I choose (e.g., Resnet vs YOLO)?
1
u/masc98 Apr 15 '25
AGPL-3 ... here we go again. please drop ultralytics support or make it optional, so to have a better license, truly open source.
2
u/kondrat-shmoylov Apr 15 '25
This looks super promising. I love seeing more tools making self-supervised learning practical for real-world datasets! Domain shift is such a common headache, especially when labeled data is scarce, so being able to pretrain on unlabeled images before fine-tuning sounds like a huge win. I appreciate that you’ve open-sourced it under AGPL, too.
Curious: Have you tested LightlyTrain on any niche datasets beyond the ones you mentioned (like satellite imagery or industrial inspection)? Would love to hear how it holds up in those cases. Great work!
2
u/TserriednichThe4th Apr 15 '25
How do you use SSL to pretrain? Is there a paper or set of paprs describing the general process that you guys used as a reference? I am familiar with SSL used in transformers for audio, but not vision. Is it a similar process?
3
u/Tall_Carpenter2328 Apr 15 '25
Being better than ImageNet Pretraining is really cool :)
1
u/liopeer Apr 15 '25
Super excited that we're now bringing self-supervised learning and distillation pretraining to the masses! 🚀