Skip to content

feat: add LeJEPA transform#1924

Draft
gabrielfruet wants to merge 3 commits into
lightly-ai:masterfrom
gabrielfruet:gabriel-trn-2032-implement-lejepa-transform
Draft

feat: add LeJEPA transform#1924
gabrielfruet wants to merge 3 commits into
lightly-ai:masterfrom
gabrielfruet:gabriel-trn-2032-implement-lejepa-transform

Conversation

@gabrielfruet

@gabrielfruet gabrielfruet commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new LeJEPATransform for LeJEPA-style multi-view augmentation. The exact augmentation configuration is not explicit in the paper, they only say they use 2 global views and 2 local views.

What’s included

  • New lightly.transforms.lejepa_transform implementation
  • Export from lightly.transforms
  • Docs entry in docs/source/lightly.transforms.rst
  • Unit test coverage for PIL input / multi-view output shape

Notes

  • Produces 2 global views + configurable local views
  • Supports crop/flip/rotation/color jitter/blur/solarization/normalization options

Testing

  • Added tests/transforms/test_lejepa_transform.py

@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.17241% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.13%. Comparing base (5aa9d51) to head (89e4807).

Files with missing lines Patch % Lines
lightly/transforms/lejepa_transform.py 53.57% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1924      +/-   ##
==========================================
- Coverage   86.26%   86.13%   -0.13%     
==========================================
  Files         170      171       +1     
  Lines        7104     7133      +29     
==========================================
+ Hits         6128     6144      +16     
- Misses        976      989      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gabrielfruet gabrielfruet marked this pull request as ready for review May 13, 2026 15:38
@gabrielfruet gabrielfruet requested a review from Copilot May 13, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new LeJEPATransform to the lightly.transforms package to generate LeJEPA-style multi-view augmentations (2 global views + configurable local views), along with docs and a basic unit test.

Changes:

  • Introduces lightly.transforms.lejepa_transform.LeJEPATransform (and internal LeJEPAViewTransform) implementing a DINO/iBOT-like multi-crop augmentation pipeline.
  • Exports LeJEPATransform from lightly.transforms and documents the new module in Sphinx docs.
  • Adds a unit test verifying PIL input produces the expected number of views and output shapes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
lightly/transforms/lejepa_transform.py New LeJEPA multi-view transform implementation (global + local views) built from torchvision-compatible augmentations.
lightly/transforms/__init__.py Exposes LeJEPATransform at the package level for public import.
docs/source/lightly.transforms.rst Adds Sphinx automodule entry so the new transform appears in documentation.
tests/transforms/test_lejepa_transform.py Adds a shape/length test for multi-view output on PIL input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lightly/transforms/lejepa_transform.py Outdated
Comment thread lightly/transforms/lejepa_transform.py
Comment thread lightly/transforms/lejepa_transform.py
gabrielfruet and others added 3 commits May 18, 2026 11:40
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@gabrielfruet gabrielfruet force-pushed the gabriel-trn-2032-implement-lejepa-transform branch from 139a177 to 89e4807 Compare May 18, 2026 09:41
@gabrielfruet gabrielfruet marked this pull request as draft May 18, 2026 10:48
@RecreationalMath

Copy link
Copy Markdown
Contributor

Hi @gabrielfruet - happy to move this along, let me know if you need a helping hand.
Or if there is any other LeJEPA work pending, happy to take it up.

@gabrielfruet

Copy link
Copy Markdown
Contributor Author

Hey @RecreationalMath thank you!

I decided to not go over with the LeJEPA transform implementation since it's basically a DINO with some different parameters.

IDK if that's is of your interest, but are you into world models ? (e.g LeWM, SubJEPA and so on)

@RecreationalMath

Copy link
Copy Markdown
Contributor

Looking at it, the overlap with DINO is my read too.

IDK if that's is of your interest, but are you into world models ? (e.g LeWM, SubJEPA and so on)

Yes. I've been reading the papers and looking at the trajectory. Any plans to implement them in lightly?

@gabrielfruet

Copy link
Copy Markdown
Contributor Author

We can discuss more into it also. We think it's valuable to have something of world models at LightlySSL. Any suggestions, ideas, paper are surely welcome :)

Currently we are prioritizing LightlyTrain, so I'm not having much time to research world models stuff for LightlySSL.

Since the philosophy of LightlySSL is providing building blocks, implementation of losses of world models, or predictor architectures are surely welcome.

FYI, we were able to benchmark LeJEPA and the metrics are very similar to the papers! Thank you so much for the high quality contributions.

@RecreationalMath

Copy link
Copy Markdown
Contributor

Good to hear the LeJEPA benchmark held up against the paper.

The smallest natural building blocks for LeWM I see are a JEPA-style predictor module and a next-embedding prediction loss. SIGReg is already in place as the regularizer, so the new surface is small. Sub-JEPA's MultiSubspaceSIGReg can follow afterwards.

Shall I open a tracking issue with the proposed scope first for a sanity check?

@gabrielfruet

Copy link
Copy Markdown
Contributor Author

I would appreciate if you could open an issue for that. We can better refine the scope.

We are very open to suggestions in this world model field, so feel free to be creative and give suggestions.

@RecreationalMath

Copy link
Copy Markdown
Contributor

Opened #1934 with some initial thoughts, findings and reasoning. Would appreciate your input there, @gabrielfruet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants