ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.55k stars 16.3k forks source link

albumentation RandomRotate90 + segmentation = incorrectly applied augmentation ? #10841

Closed ExtReMLapin closed 1 year ago

ExtReMLapin commented 1 year ago

Search before asking

YOLOv5 Component

Training

Bug

related to #10273 and especially https://github.com/ultralytics/yolov5/issues/10273#issuecomment-1363621395

I usualy use RandomRotate90 in util augmentations, because i work with detection, but it seems to be broken with segmentation; Please see image attached, especially the second one.

image

No need to give code to reproduce as it's just one line in augmentations.py

Environment

YOLOv5 on HEAD

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

github-actions[bot] commented 1 year ago

👋 Hello @ExtReMLapin, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com.

Requirements

Python>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

YOLOv5 CI

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training, validation, inference, export and benchmarks on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

ExtReMLapin commented 1 year ago

So far no issues with hyp augmentations, only albumentation ones.

JustasBart commented 1 year ago

@ExtReMLapin I can confirm that there does seem to be a major issue with the Rotate parameter of the Augmentations. Have you seen #10639?

ExtReMLapin commented 1 year ago

@JustasBart Are your 360° dons in the hyp files ? Or in albumentation ?

I use +/- 180° aug rotation un hyp file (as you can see in my first screenshot as the images are not straight) but I don't see any label messed up.

I wouldn't not be surprised to learn that on your problem, it's because the bbox of the original segmentation is rotated instead of the segmentation itself and the new bbox is calculated on old bbox rotated instead of new segmentation rotated.

JustasBart commented 1 year ago

@ExtReMLapin If I do it on the hyp file it seems to break it for me...

ExtReMLapin commented 1 year ago

You're using the latest yolo version ? Because see it for yourself, no issue on my end.

image

JustasBart commented 1 year ago

@ExtReMLapin If I do it on my Object Detection labels:

train_batch0 train_batch1 train_batch2

Note how the labels just expand by a huge margin...

Hyps: image

ExtReMLapin commented 1 year ago

I doubt it's a bug, but I set it to 180, not 360 as +180 or -180 already equals 360.

I'm not at the office so I can't really compare the hyps but I also had to disable mosaic as it was causing a numpy error; Weird to see it works on your end. But my hyp was based on hyp high with just rotate to 180 and mosaic to zero (from memory)

Are you sure you didn't edit your augmentations.py file ? And you're up to date with the repo code (git pull) ?

JustasBart commented 1 year ago

@ExtReMLapin This is what it looks like on 180:

train_batch0 train_batch1 train_batch2

I've tried different values in the past such as 45 etc... None have worked for me thus far.

JustasBart commented 1 year ago

@ExtReMLapin Sorry, yes, I'm on the latest, but I'm also on --rect mode whenever I train, that could very well be my issue as well...

ExtReMLapin commented 1 year ago

@ExtReMLapin Sorry, yes, I'm on the latest, but I'm also on --rect mode whenever I train, that could very well be my issue as well...

https://www.youtube.com/watch?v=gyZDZCGQJf8

JustasBart commented 1 year ago

@ExtReMLapin No, the labels are still broken even with --rect disabled so it's not it either...

train_batch0 train_batch1 train_batch2

ExtReMLapin commented 1 year ago

Show me your command line

JustasBart commented 1 year ago

@ExtReMLapin Here's the example with the --rect enabled again:

python3 train.py \
--data /home/ash/10_Class_dataset/10Class.yaml \
--hyp data/hyps/hyp.scratch-custom.yaml \
--weights yolov5s6.pt \
--img 1280 \
--batch -1 \
--epochs 600 \
--device 0 \
--rect
ExtReMLapin commented 1 year ago

When you claim to "disable" rect, you simply strip it straight from the command line,right, you don't do something like "--rect false", right ?

JustasBart commented 1 year ago

When you claim to "disable" rect, you simply strip it straight from the command line,right, you don't do something like "--rect false", right ?

Yes, that's right, I just don't mention it which defaults to a square input.

ExtReMLapin commented 1 year ago

I have no idea then, for reference, here is my commandline, straight from wandb.

train.py --img 2048 --batch 11 --epochs 1250 --data diatomees_seg.yaml --weights " " --cfg yolov5n6-seg.yaml --hyp hyp.scratch-high.yaml --patience 0 --cache disk

JustasBart commented 1 year ago

@ExtReMLapin It could even be just the fact that you're doing Segmentation whereas I'm doing Object Detection, but yeah, I haven't been able to figure this out just yet...

ExtReMLapin commented 1 year ago

Well here if you're doing detection, yes obviously it's not really surprising but it should still recalc the bbox on the rotated segmentation, not out of the old bbox

JustasBart commented 1 year ago

@ExtReMLapin Yeah, that's what I would think as well I mean it should still fundamentally just do it if it were working the way that it should... This augmentation makes perfect sense for Object Detection.

github-actions[bot] commented 1 year ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

ExtReMLapin commented 1 year ago

Stale, yes, fixed, no !

JustasBart commented 1 year ago

Hi @ExtReMLapin I've actually recently enough realized that the rotation Augmentation makes absolutely no sense at all for Object Detection so I'm personally done with talking about it :laughing:

All the best to you! :rocket:

ExtReMLapin commented 1 year ago

Sure, no issue on that but there is still issues (bugs) with albumentation and segmentation

github-actions[bot] commented 1 year ago

👋 Hello, this issue has been automatically marked as stale because it has not had recent activity. Please note it will be closed if no further activity occurs.

Access additional YOLOv5 🚀 resources:

Access additional Ultralytics ⚡ resources:

Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed!

Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐!

glenn-jocher commented 11 months ago

Hi @ExtReMLapin! Absolutely, there may be some issues with albumentation and segmentation. Your report is invaluable for improving the YOLOv5 experience for everyone. Our team appreciates your feedback, and we're actively addressing these concerns. Thanks for your understanding and patience! If you need further assistance, feel free to reach out. All the best!