Augmentor¶
dataphy.dataset.augmentor
¶
Dataset augmentation functionality for Dataphy SDK.
Classes¶
AugmentationConfig(pipeline_config: Union[str, Path, Dict[str, Any]], target: str = 'dataset', episode_ids: Optional[List[str]] = None, timestep_range: Optional[tuple[int, int]] = None, random_seed: Optional[int] = None, output_path: Optional[Union[str, Path]] = None, num_augmented_episodes: int = 1, camera_streams: Optional[List[str]] = None, preserve_original: bool = True, progress_callback: Optional[Callable[[str, int, int], None]] = None, sync_views: bool = False)
dataclass
¶
Configuration for dataset augmentation.
This dataclass defines all parameters needed to configure dataset augmentation, including pipeline settings, target scope, episode selection, and output options.
Attributes¶
pipeline_config: Union[str, Path, Dict[str, Any]]
instance-attribute
¶
target: str = 'dataset'
class-attribute
instance-attribute
¶
episode_ids: Optional[List[str]] = None
class-attribute
instance-attribute
¶
timestep_range: Optional[tuple[int, int]] = None
class-attribute
instance-attribute
¶
random_seed: Optional[int] = None
class-attribute
instance-attribute
¶
output_path: Optional[Union[str, Path]] = None
class-attribute
instance-attribute
¶
num_augmented_episodes: int = 1
class-attribute
instance-attribute
¶
camera_streams: Optional[List[str]] = None
class-attribute
instance-attribute
¶
preserve_original: bool = True
class-attribute
instance-attribute
¶
progress_callback: Optional[Callable[[str, int, int], None]] = None
class-attribute
instance-attribute
¶
sync_views: bool = False
class-attribute
instance-attribute
¶
DatasetAugmentor(dataset_loader: BaseDatasetLoader)
¶
Augmentor for applying transformations to datasets.
This class provides comprehensive dataset augmentation capabilities, supporting both episode-level and dataset-level augmentation with memory-efficient processing and progress tracking.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_loader
|
BaseDatasetLoader
|
The dataset loader to use for accessing episodes |
required |
Source code in src/dataphy/dataset/augmentor.py
Attributes¶
dataset_loader = dataset_loader
instance-attribute
¶
pipeline = None
instance-attribute
¶
Functions¶
load_pipeline(config: Union[str, Path, Dict[str, Any]])
¶
Load augmentation pipeline from configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Union[str, Path, Dict[str, Any]]
|
Pipeline configuration (file path, dict, or Config object) |
required |
Source code in src/dataphy/dataset/augmentor.py
augment_episode(episode_id: str, pipeline: Optional[Any] = None) -> Episode
¶
Augment a single episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
episode_id
|
str
|
ID of the episode to augment |
required |
pipeline
|
Optional[Any]
|
Optional pipeline to use (uses loaded pipeline if None) |
None
|
Returns:
| Type | Description |
|---|---|
Episode
|
Augmented episode with transformed data |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no pipeline is available |
Source code in src/dataphy/dataset/augmentor.py
augment_timestep(episode_id: str, timestep: int, pipeline=None) -> Dict[str, Any]
¶
Augment a single timestep.
Source code in src/dataphy/dataset/augmentor.py
augment_timesteps(episode_id: str, start: int, end: int, pipeline=None) -> List[Dict[str, Any]]
¶
Augment a range of timesteps.
augment_dataset(config: AugmentationConfig) -> List[Episode]
¶
Augment dataset according to configuration.
Source code in src/dataphy/dataset/augmentor.py
augment_full_dataset(config: AugmentationConfig, output_path: Union[str, Path]) -> Dict[str, Any]
¶
Augment entire dataset creating new episodes with specified parameters.
This method creates a completely new dataset with: - All original episodes (if preserve_original=True) - Specified number of augmented versions per episode - Updated metadata reflecting the expanded dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
AugmentationConfig
|
Augmentation configuration with dataset-level parameters |
required |
output_path
|
Union[str, Path]
|
Path where the new augmented dataset will be saved |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dictionary with augmentation results and metadata |
Source code in src/dataphy/dataset/augmentor.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
save_augmented_dataset(episodes: List[Episode], output_path: Union[str, Path])
¶
Save augmented episodes to disk.