Augmentation error  Expected y_max for bbox evoked in the trainer.train() to finetune object detection detr model
Author: ironllamagirl
Pull request: no

### System Info


- `transformers` version: 4.31.0
- Platform: Linux-5.15.0-1039-oracle-x86_64-with-glibc2.35
- Python version: 3.11.4
- Huggingface_hub version: 0.16.4
- Safetensors version: 0.3.1
- Accelerate version: 0.21.0
- Accelerate config: 	not found
- PyTorch version (GPU?): 2.0.1+cu117 (True)
- Tensorflow version (GPU?): not installed (NA)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>


and albumentation version: 1.3.1 



### Who can help?

@amyeroberts

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

I am following [this tutorial ](https://huggingface.co/docs/transformers/tasks/object_detection) to finetune a detr on my custom dataset. 

the problem arises when I call trainer.train(). This is the error I'm getting 
`ValueError: Expected y_max for bbox (0.4921875, 0.9018518518518519, 0.5375, 1.026851851851852, 3) to be in the range [0.0, 1.0], got 1.026851851851852.`

I saw that this is an issue related to albumentations [here](https://github.com/albumentations-team/albumentations/issues/459) And I'm looking for a workaround where I do not have to modify the package (albumentations package) source code. 
What would be the data augmentations that I can perform that would make sure I do run through this error whatever the data I use? Is there a way to disable the augmentations?

I also wanted to implement the logic of 'clipping' the bounding box coordinates to either 0 or 1 if  they are outside the range but it seems like the augmentations are done within the trainer.train()? . I'm concluding this since when I print the bbox coordinates before running .train() I do not have values outside of the {0,1] range. 


Thank you for your help!

### Expected behavior

running trainer.train() would finetune the model on augmented data

Comments:
Hi @ironllamagirl, thanks for raising this issue! 

This is really a question for the forums. We try to reserve github issues for bug reports and feature requests. However, we can give some pointers. 

In the linked example, the augmentations are applied to dataset samples whenever a new batch is loaded. During the training loop of the trainer, the dataset is iterated over and the loaded samples passed to the model. However, the trainer is not itself performing the augmentations. 

The augmentations are applied to the dataset using the `with_transform` method in [datasets](https://huggingface.co/docs/datasets/v2.14.4/en/package_reference/main_classes#datasets.Dataset.with_transform). You can see where this is applied to the dataset and the resulting augmented sampled in the example starting `cppe5["train"] = cppe5["train"].with_transform(transform_aug_ann)`. 

Disabling augmentations is just a case of not applying them in the definition of `transform`. Note: the `resize` operation is still needed in order to batch the images e.g.

```
transform = albumentations.Compose(
    [albumentations.Resize(480, 480)],
    bbox_params=albumentations.BboxParams(format="coco", label_fields=["category"]),
)
```

The logic of clipping the bounding boxes should probably go inside `formatted_anns`


cc @rafaelpadilla 


Hi @ironllamagirl,

Also note that in the provided example, some images have been omitted from the training set (`remove_idx = [590, 821, 822, 875, 876, 878, 879]`). This is due to the fact that certain bounding boxes associated with these images were entirely outside the image boundaries.

When faced with instances where bounding boxes (before augmentation) are positioned completely outside the image frame, it's better to exclude these boxes from your training dataset rather than just clipping them.


Thank you so much for your feedback. 

Yes removing those fixed the issue. Thanks!