-
Notifications
You must be signed in to change notification settings - Fork 772
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into user/rcadene/2024_06_…
…01_custom_visualize_dataset
- Loading branch information
Showing
34 changed files
with
1,754 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
on: | ||
push: | ||
|
||
name: Secret Leaks | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
trufflehog: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Secret Scanning | ||
uses: trufflesecurity/trufflehog@main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
""" | ||
This script demonstrates how to use torchvision's image transformation with LeRobotDataset for data | ||
augmentation purposes. The transformations are passed to the dataset as an argument upon creation, and | ||
transforms are applied to the observation images before they are returned in the dataset's __get_item__. | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
from torchvision.transforms import ToPILImage, v2 | ||
|
||
from lerobot.common.datasets.lerobot_dataset import LeRobotDataset | ||
|
||
dataset_repo_id = "lerobot/aloha_static_tape" | ||
|
||
# Create a LeRobotDataset with no transformations | ||
dataset = LeRobotDataset(dataset_repo_id) | ||
# This is equivalent to `dataset = LeRobotDataset(dataset_repo_id, image_transforms=None)` | ||
|
||
# Get the index of the first observation in the first episode | ||
first_idx = dataset.episode_data_index["from"][0].item() | ||
|
||
# Get the frame corresponding to the first camera | ||
frame = dataset[first_idx][dataset.camera_keys[0]] | ||
|
||
|
||
# Define the transformations | ||
transforms = v2.Compose( | ||
[ | ||
v2.ColorJitter(brightness=(0.5, 1.5)), | ||
v2.ColorJitter(contrast=(0.5, 1.5)), | ||
v2.RandomAdjustSharpness(sharpness_factor=2, p=1), | ||
] | ||
) | ||
|
||
# Create another LeRobotDataset with the defined transformations | ||
transformed_dataset = LeRobotDataset(dataset_repo_id, image_transforms=transforms) | ||
|
||
# Get a frame from the transformed dataset | ||
transformed_frame = transformed_dataset[first_idx][transformed_dataset.camera_keys[0]] | ||
|
||
# Create a directory to store output images | ||
output_dir = Path("outputs/image_transforms") | ||
output_dir.mkdir(parents=True, exist_ok=True) | ||
|
||
# Save the original frame | ||
to_pil = ToPILImage() | ||
to_pil(frame).save(output_dir / "original_frame.png", quality=100) | ||
print(f"Original frame saved to {output_dir / 'original_frame.png'}.") | ||
|
||
# Save the transformed frame | ||
to_pil(transformed_frame).save(output_dir / "transformed_frame.png", quality=100) | ||
print(f"Transformed frame saved to {output_dir / 'transformed_frame.png'}.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.