Add support slice function, padding the mask to the full images and t… #881
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces support for InferenceSlicer that focuses on segmentation. This is the second part of the discussion in the #678 issue.
First, I added a conditional statement to pad images that were smaller than the slice size, such as corners. Next, I created the
_apply_padding_to_slice
function to apply padding to a slice using the letterbox resizing method.We are adjusting the masks to align them with the image coordinate system, which represents the entire image. Most of the masks are empty except for the specific area we want to focus on. This simplifies the process of merging all the masks, but it also requires more memory since the size of each mask will be the same as the original image. Besides, we are currently using a
concatenate
function to join all the masks in themerge
functionThe main difficulty lies in the high computational cost and time required by this method. The algorithm needs to fit every mask detection in the entire image, resulting in a significantly larger size of the data.
In my opinion, this PR is not ready for production yet, as we need to handle the computational cost for the mask. However, I would like to hear your perspective @SkalskiP
Currently, the method is consuming a lot of RAM.
In addition, this PR encompasses comprehensive unit tests for the new move_masks functionality and a demo that demonstrates the algorithm's application and effectiveness in real-world scenarios.
Type of change
New feature (non-breaking change which adds functionality)
How has this change been tested
I created a demo to showcase this functionality here