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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Q] Possible to merge overlapping tiles of a multi-class discrete model output using max strategy? #23

Closed
cwerner opened this issue Mar 2, 2023 · 3 comments

Comments

@cwerner
Copy link

cwerner commented Mar 2, 2023

Hi 馃憢

I just found your library as I was browsing for a tiler/ merger solution to replace my crappy custom code that cannot handle overlap.

I'm looking for a library that lets me split a source images (3-channel, 2048x2048px) into overlapping 3-channel tiles with size 256x256px (overlap width=32px in x and y direction).

I'm feeding my segmentation model batches of those tiles. The results are 1-channel images of size 256x256 (values are multi-class integer results: currently classes 0,1,2).

So the flow is:

  1. Source: 2048x2048 RGB image
  2. Convert to batches of 256x256 RGB tiles (that overlap by 32px): 9x9 tiles in total (with Tiler()?), non-overlapping it is 8x8 tiles
  3. Run my model with those tiles
  4. The model returns 81x 256x256 data tiles
  5. Use merger to reconstruct a 2048x2048 monochrom image (with discrete class ids: 0, 1, 2) - in the overlap regions I would need to use the max value (no average or blending)

If I understand the library correctly, overlapping tiles are merged and the values are averaged? In my case, I'd have to take the max value in an overlap area. Is this supported? Could I adapt the code to take the max instead of the mean? And if so: are there any examples how to do this?

Cheers and thanks for any hints

@cwerner
Copy link
Author

cwerner commented Mar 9, 2023

I just worked around it be simply adding the raw model logits and doing the argmax after merging everything with tiler. So this can be closed I guess...

@cwerner cwerner closed this as completed Mar 9, 2023
@the-lay
Copy link
Owner

the-lay commented Mar 14, 2023

Hi, apologies for taking so long to reply!
Glad you have made it work!

@cwerner
Copy link
Author

cwerner commented Mar 14, 2023

No problem 馃槈 nice little library by the way - just what I needed 馃憤

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

No branches or pull requests

2 participants