Episode Augmentor¶
dataphy.dataset.episode_augmentor
¶
Episode-specific augmentation with camera stream selection and repackaging.
Classes¶
EpisodeAugmentor(dataset_loader: BaseDatasetLoader)
¶
Augment specific episodes with camera stream selection and synchronized views.
This class provides functionality to apply VisionPack augmentations to individual episodes in LeRobot datasets, with support for:
- Episode-specific targeting (by name or index)
- Camera stream selection for multi-camera setups
- Synchronized augmentations across cameras (sync_views)
- Automatic backup and restore functionality
- In-place video repackaging in original format
The augmentation process extracts frames from videos, applies VisionPack transforms, and repackages them back into MP4 files while preserving the original dataset structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_loader
|
BaseDatasetLoader
|
The dataset loader instance to use for accessing episodes |
required |
Example
from dataphy.dataset.registry import create_dataset_loader
from dataphy.dataset.episode_augmentor import EpisodeAugmentor
# Load dataset
loader = create_dataset_loader("./dataset")
augmentor = EpisodeAugmentor(loader)
# Augment first episode, all cameras
augmentor.augment_episode(
episode_id=0,
config_file="config.yaml"
)
# Augment specific camera
augmentor.augment_episode(
episode_id="episode_000000",
config_file="config.yaml",
camera_streams=["observation.images.webcam"]
)
Source code in src/dataphy/dataset/episode_augmentor.py
Attributes¶
loader = dataset_loader
instance-attribute
¶
dataset_path = dataset_loader.dataset_path
instance-attribute
¶
Functions¶
get_available_cameras(episode_id: str) -> List[str]
¶
Get list of available camera streams for an episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_id
|
str
|
Episode ID to check for available cameras |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List of camera stream names (e.g., ['observation.images.webcam', 'observation.images.laptop']) |
Example
Source code in src/dataphy/dataset/episode_augmentor.py
augment_episode(episode_id: Union[str, int], config_file: Union[str, Path], camera_streams: Optional[List[str]] = None, preserve_original: bool = True) -> str
¶
Augment a specific episode with selected camera streams.
This method applies VisionPack augmentations to video frames from specified camera streams in an episode. The process includes:
- Episode validation and camera stream selection
- Automatic backup creation (if preserve_original=True)
- Frame extraction from video files
- VisionPack augmentation pipeline application
- Video repackaging with augmented frames
- Synchronized augmentation across cameras (if sync_views=True in config)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_id
|
Union[str, int]
|
Episode to augment. Can be:
- Episode name (e.g., "episode_000000") |
required |
config_file
|
Union[str, Path]
|
Path to VisionPack YAML configuration file |
required |
camera_streams
|
Optional[List[str]]
|
Camera streams to augment. Options: - None: Augment all available cameras (default) - List of camera names (e.g., ["observation.images.webcam"]) |
None
|
preserve_original
|
bool
|
Whether to backup original files before augmentation |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Path to the dataset directory containing augmented episodes |
Raises:
| Type | Description |
|---|---|
ValueError
|
If episode not found, no cameras available, or invalid camera specified |
FileNotFoundError
|
If config file not found |
Example
# Augment by episode index with specific camera
augmentor.augment_episode(
episode_id=0,
config_file="aug.yaml",
camera_streams=["observation.images.webcam"]
)
# Augment by episode name, all cameras
augmentor.augment_episode(
episode_id="episode_000000",
config_file="config.yaml"
)
# Synchronized multi-camera augmentation
augmentor.augment_episode(
episode_id=5,
config_file="sync_config.yaml", # sync_views: true
camera_streams=["observation.images.webcam", "observation.images.laptop"]
)
Source code in src/dataphy/dataset/episode_augmentor.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
restore_episode(episode_id: str)
¶
Restore episode from backup.
Source code in src/dataphy/dataset/episode_augmentor.py
list_episodes() -> List[str]
¶
list_backups() -> List[str]
¶
List episodes that have backups.