Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce mosaic augmentation #1007

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft

Conversation

potipot
Copy link
Contributor

@potipot potipot commented Dec 21, 2021

Fixes #587

  • figure out how to attach mosaic as batch_tfms
  • implement bbox unaware mosaic
  • implement bbox safe crop mosaic with scaling
  • implement bbox safe crop without scaling (requires new Albumentation transform)
  • add tests (especially for negative samples - what happens if there is no bbox to "safely crop"?)

@potipot
Copy link
Contributor Author

potipot commented Dec 21, 2021

some early results for bbox unaware mosaic
image

@potipot potipot marked this pull request as draft December 21, 2021 10:22
@codecov
Copy link

codecov bot commented Dec 21, 2021

Codecov Report

Merging #1007 (e4b74db) into master (4050e0e) will decrease coverage by 0.28%.
The diff coverage is 54.00%.

❗ Current head e4b74db differs from pull request most recent head b7e64f1. Consider uploading reports for the commit b7e64f1 to get more accurate results

@@            Coverage Diff             @@
##           master    #1007      +/-   ##
==========================================
- Coverage   85.88%   85.59%   -0.29%     
==========================================
  Files         255      256       +1     
  Lines        5631     5679      +48     
==========================================
+ Hits         4836     4861      +25     
- Misses        795      818      +23     
Flag Coverage Δ
unittests 85.59% <54.00%> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
icevision/tfms/batch/mosaic.py 48.88% <48.88%> (ø)
icevision/data/record_collection.py 100.00% <100.00%> (ø)
...sion/tfms/albumentations/albumentations_adapter.py 96.25% <100.00%> (ø)
icevision/tfms/batch/__init__.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@potipot
Copy link
Contributor Author

potipot commented Dec 21, 2021

bbox aware mosaic with enforced scaling
image

@potipot
Copy link
Contributor Author

potipot commented Dec 21, 2021

what I want to achieve with non-scaling mosaic is keeping the original size of objects. The current scaled mosaic tries to encircle all of the bboxes in an image and make such crop, that will include all of the objects.

Another, smarter approach is to select exclusive areas in an image that can be cropped out and used as "pieces" in the mosaic.

@dav-ell
Copy link

dav-ell commented Mar 14, 2022

Can this be merged? It looks fantastic, and I've been struggling trying to implement one myself.

@potipot
Copy link
Contributor Author

potipot commented Mar 15, 2022

@dav-ell Oh wow! I completely forgot about this one. Yeah I'll sync master changes and try to merge it as is. (the non-scaling mosaic aug is still TBD but if you find it useful as is then I'd say let's merge!)

@dav-ell
Copy link

dav-ell commented Mar 15, 2022

Thanks @potipot!

What a shame that I just finished my own custom implementation that I referenced here: albumentations-team/albumentations#677 (comment)

The good news is that this one has more features than mine, so I'll almost definitely be switching over once it's in.

@Modius22
Copy link

This looks great. I am also looking for a similar functionality for object detection.
I hope it can be merged soon =)

@mikel-brostrom
Copy link

Any update on this?

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@potipot
Copy link
Contributor Author

potipot commented Jan 17, 2023

Hi @mikel-brostrom, it's been a while since I worked on this. I just checked and it should be working. Do you mind giving it a try? you can install this PR in your venv by

pip install git+https://github.com/potipot/icevision@add_mosaic#egg=icevision[all]

here is the notebook showcasing how to use the mosaic tfm:
https://github.com/potipot/icevision/blob/add_mosaic/notebooks/mosaic.ipynb

if it works for you I could put some more time into it and try to merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Mosaic Data Augmentation
4 participants