feat(datasets): improve image transform support#2885
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the image transform support in the LeRobot datasets module by allowing any torchvision v2 transform to be used, replacing the previously hardcoded list of supported transforms.
Changes:
- Refactored
make_transform_from_configto dynamically load any valid torchvision v2 transform usinghasattrandgetattr - Added tests for the new dynamic transform loading feature (Resize transform) and error handling for invalid transform names
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lerobot/datasets/transforms.py | Replaced hardcoded transform type checks with dynamic attribute lookup in torchvision.transforms.v2, while maintaining special handling for SharpnessJitter |
| tests/datasets/test_image_transforms.py | Added two new tests: one for validating a new v2 transform (Resize) and one for error handling with invalid transform types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @reeceomahoney, Thank you for your contribution ! Before merging your PR, would It be possible to tackle these two issues :
Once done, feel free to ping me for the merge ! Best, Caroline. |
936acea to
30d108a
Compare
|
@CarolinePascal these changes have been made |
CarolinePascal
left a comment
There was a problem hiding this comment.
Looks good to me, thanks !
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @reeceomahoney, I left a comment under Copilot's review ;) |
|
@CarolinePascal fixed, have removed the need for the hasattr check too |
CarolinePascal
left a comment
There was a problem hiding this comment.
Awesome, let's merge !
* improve image transform support * add tests * Add stricter transform check and extra test * improve subclass check
* improve image transform support * add tests * Add stricter transform check and extra test * improve subclass check
* improve image transform support * add tests * Add stricter transform check and extra test * improve subclass check
Type / Scope
Summary / Motivation
Related issues
What changed
make_transform_from_configfunction to accept any valid torchvision v2 transform rather than just the hardcoded list of options that existedHow was this tested (or how to run locally)
Checklist (required before merge)
pre-commit run -a)pytest)Reviewer notes