§
    ­¸j¥%  ã            
       ó¬   — d Z dddiiZddiddddœdœZddiddiddd	œd
dddddœddddddœdœZddiddiddd	œddddœdœZddiddddœdddœdddœdœZdS )u�  Optional Albumentations augmentation presets for RF-DETR training.

RF-DETR's default training augmentation path is torchvision-native and does not require Albumentations. Importing and
passing the presets in this module as ``aug_config`` uses the optional Albumentations integration; install it with
``pip install 'rfdetr[augment]'``.

Import a preset and pass it as ``aug_config`` to your training call:

```python
from rfdetr.datasets.aug_configs import AUG_CONSERVATIVE, AUG_AGGRESSIVE, AUG_AERIAL, AUG_INDUSTRIAL

model.train(dataset_dir="...", aug_config=AUG_CONSERVATIVE) model.train(dataset_dir="...", aug_config=AUG_AGGRESSIVE)

# Disable all augmentations
model.train(dataset_dir="...", aug_config={})

# Fully custom
model.train(dataset_dir="...", aug_config={"HorizontalFlip": {"p": 0.5}})
```

## Available presets

| Preset         | Best for                                         |
| -------------- | ------------------------------------------------ |
| ``AUG_CONSERVATIVE``  | Small datasets (under 500 images)             |
| ``AUG_AGGRESSIVE``    | Large datasets (2000+ images)                 |
| ``AUG_AERIAL``        | Satellite / overhead imagery                  |
| ``AUG_INDUSTRIAL``    | Manufacturing / inspection data               |

## Transform Categories

**Geometric transforms** (automatically transform bounding boxes; this representative list is not exhaustive):
- Flips and square symmetries: HorizontalFlip, TimeReverse, VerticalFlip, D4, SquareSymmetry
- Rotations: Rotate, Affine, ShiftScaleRotate
- Crops: RandomCrop, CenterCrop, RandomResizedCrop
- Perspective: Perspective, ElasticTransform, GridDistortion

**Pixel-level transforms** (preserve bounding boxes):
- Color: ColorJitter, HueSaturationValue, RandomBrightnessContrast, ToGray
- Blur/Noise: GaussianBlur, GaussNoise, Blur
- Enhancement: CLAHE, Sharpen, Equalize

## Best Practices

1. **Start conservative**: Use moderate probabilities (p=0.3-0.5) and small parameter ranges
2. **Geometric caution**: Extreme rotations (>45Â°) or crops may remove too many boxes
3. **Keypoint safety**: Keypoint pipelines with an empty `keypoint_flip_pairs` list disable
   all horizontal-flip-capable aliases, including `TimeReverse`, `D4`, and `SquareSymmetry`;
   provide left/right pairs to retain them.
4. **Performance**: Fewer transforms = faster training; prioritize transforms that match your domain
5. **Validation**: Monitor validation mAP - excessive augmentation can hurt performance
6. **Domain-specific**: Enable augmentations that reflect real-world variations in your data

## Adding Custom Transforms

For geometric transforms not in GEOMETRIC_TRANSFORMS set, add them in transforms.py:

```python
GEOMETRIC_TRANSFORMS = {
    ...
    "YourCustomTransform",  # Add here
}
```

## Kornia GPU Backend

When ``augmentation_backend="kornia"`` is set in ``TrainConfig`` (or ``"auto"``/``"cpu"`` resolves to it because
Kornia is installed and CUDA is available), augmentations run on the GPU via Kornia instead of CPU Albumentations
or torchvision defaults. Install it with ``pip install 'rfdetr[augment]'``.

**Supported transforms** (all presets):

| Preset key | Kornia equivalent | Notes |
|---|---|---|
| ``HorizontalFlip`` | ``K.RandomHorizontalFlip`` | Direct |
| ``VerticalFlip`` | ``K.RandomVerticalFlip`` | Direct |
| ``Rotate`` | ``K.RandomRotation`` | ``limit`` may be scalar or tuple |
| ``Affine`` | ``K.RandomAffine`` | ``translate_percent`` fraction; scalar -> signed; CPU warning; scale -> ``(v, v)`` |
| ``ColorJitter`` | ``K.ColorJiggle`` | Same multiplicative semantics |
| ``ToGray`` | ``K.RandomGrayscale`` | Grayscale, 3 channels; only ``p`` honored, method/num_output_channels ignored |
| ``RandomBrightnessContrast`` | ``K.ColorJiggle`` | ``brightness_limit`` / ``contrast_limit`` direct |
| ``GaussianBlur`` | ``K.RandomGaussianBlur`` | ``blur_limit`` rounded up to odd; ``sigma`` mirrors Albumentations |
| ``GaussNoise`` | ``K.RandomGaussianNoise`` | Upper bound of ``std_range`` used as fixed std |
| ``Blur`` | ``K.RandomBoxBlur`` | Box blur; ``blur_limit`` rounded up to odd, pair collapses to its upper bound |
| ``Sharpen`` | ``K.RandomSharpness`` | ``sharpness = 1.0 + alpha`` (1.0-pivoted); ``lightness``/``method`` ignored |
| ``Equalize`` | ``K.RandomEqualize`` | Only ``p`` honored; ``mode``/``by_channels``/``mask`` ignored |
| ``CLAHE`` | ``K.RandomClahe`` | Scalar ``clip_limit=v`` -> ``(1, v)``; pairs and ``tile_grid_size`` pass through |
| ``Perspective`` | ``K.RandomPerspective`` | Approximate; see the note below. ``keep_size=False`` raises |
| ``ShiftScaleRotate`` | ``K.RandomAffine`` | Limits are deltas, not absolute ranges; see the note below |

``Perspective`` is the one entry in the table that is not a faithful mapping. Albumentations samples each
corner offset from ``abs(N(0, scale))``, Kornia samples uniformly from ``distortion_scale``, so the two
produce different distortion distributions for the same config. The upper bound of ``scale`` is used as
``distortion_scale`` and a scalar ``scale`` is read as ``(0, scale)``; the divergence is logged for every
config, not only for a range. ``keep_size=False`` raises rather than silently resizing, and
``fit_output``, ``interpolation``,
``mask_interpolation``, ``border_mode``, ``fill`` and ``fill_mask`` are ignored. Use the Albumentations
backend when the exact Albumentations semantics matter.

``ShiftScaleRotate`` maps onto the same ``K.RandomAffine`` as ``Affine``, which is what makes it safe here:
it preserves the output resolution, so the padding-mask constraint that keeps the crops unsupported does not
apply. Its limits are deltas rather than absolute ranges, so they are converted rather than forwarded.
``scale_limit`` is biased by 1 in Albumentations, meaning it samples from ``(1 + low, 1 + high)``, so the
default ``(-0.1, 0.1)`` is a scale between ``0.9`` and ``1.1``; that pivot is applied here. All three limits
also read a scalar ``v`` as the symmetric ``(-v, v)``. ``shift_limit_x`` and ``shift_limit_y`` map onto
Kornia's per-axis ``translate``; ``None`` uses the shared ``shift_limit``. Kornia can sample only symmetric shift
ranges, so an asymmetric Albumentations pair such as ``(0.1, 0.2)`` becomes ``(-0.2, 0.2)`` and emits a warning.
Use the Albumentations backend when that distribution must be preserved. ``interpolation``, ``border_mode``,
``mask_interpolation``, ``fill``, ``fill_mask`` and ``rotate_method`` have no equivalent and are ignored with a warning.
Note that
Albumentations itself deprecates ``ShiftScaleRotate`` in favour of ``Affine``, which this backend already
supports; new configs should prefer ``Affine``.

Not yet supported on Kornia: ``HueSaturationValue`` (Albumentations shifts hue/saturation/value additively,
Kornia's ``ColorJiggle`` scales them multiplicatively, so there is no faithful mapping), and the geometric
group ``RandomCrop``, ``CenterCrop``, ``RandomResizedCrop``,
``ElasticTransform`` and ``GridDistortion``, whose CPU behavior is not faithfully mapped by the current
Kornia pipeline. These still work on the Albumentations backend.

The GPU augmentation path transports the padded-batch mask with every geometric transform. Segmentation models also
carry instance-mask channels in the same synchronized mask tensor.
ÚHorizontalFlipÚpg      à?çš™™™™™¹?g333333Ó?)Úbrightness_limitÚcontrast_limitr   )r   ÚRandomBrightnessContrasté-   )Úlimitr   )gš™™™™™é?g333333ó?)gš™™™™™¹¿r   )iñÿÿÿé   )éûÿÿÿé   )ÚscaleÚtranslate_percentÚrotateÚshearr   gš™™™™™É?)Ú
brightnessÚcontrastÚ
saturationÚhuer   )r   ÚVerticalFlipÚRotateÚAffineÚColorJitter)éZ   r   g333333Ã?gš™™™™™Ù?)r   r   r   r   é   )Ú
blur_limitr   )g{®Gáz„?gš™™™™™©?)Ú	std_ranger   )r   r   ÚGaussianBlurÚ
GaussNoiseN)Ú__doc__Ú
AUG_CONFIGÚAUG_CONSERVATIVEÚAUG_AGGRESSIVEÚ
AUG_AERIALÚAUG_INDUSTRIAL© ó    úk/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/rfdetr/datasets/aug_configs.pyú<module>r(      s&  ððyð yð@ �s˜C�jð€
ð ˜C�jàØØð!ð !ðð Ð ð ˜C�jØ˜#�JØ Ð%Ð%àØ(ØØØðð ð ØØØØðð ðð €ð, ˜C�jØ˜#�JØ  sÐ+Ð+à ØØð!ð !ð		ð 	€
ð ˜C�jàØØð!ð !ð
 $%¨3Ð/Ð/Ø ,°3Ð7Ð7ð	ð 	€€€r&   