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

Feat/inference slicer segmentation #1178

Merged
merged 11 commits into from May 13, 2024
Merged

Conversation

LinasKo
Copy link
Collaborator

@LinasKo LinasKo commented May 8, 2024

Description

Prerequisites:

This allows the slicer to merge segmentation masks.

Previously it would fail when attempting to stack slices of different sizes, as there'd be no attempts to move & pad the slices. The result is that each mask would be of size(slice), rather than size(image).

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How has this change been tested, please provide a testcase or example of how you tested the change?

Same notebook as for prior PR.
馃摀 Google Colab

Any specific deployment considerations

  1. Non-max suppression wrecks the visuals for large images. Best way to test would be to merge the PRs adding Non-max merging & slicer filter selector, and then test with NONE.
  2. It takes a lot of RAM and time, even for a small model. High-RAM env in Colab is needed.

Docs

  • Docs updated? What were the changes:

supervision/detection/utils.py Outdated Show resolved Hide resolved
supervision/detection/utils.py Outdated Show resolved Hide resolved
from supervision.utils.image import crop_image


def move_detections(detections: Detections, offset: np.array) -> Detections:
def move_detections(
detections: Detections, offset: np.ndarray, image_shape: np.ndarray
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argument image_shape is called resolution_wh in most places in supervision. Let's keep it this way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think it should be Optional.

@SkalskiP
Copy link
Collaborator

Also please add move_masks import to __init__.py.

def move_masks(
masks: np.ndarray,
offset: np.ndarray,
desired_shape: Optional[Union[Tuple[int, int, int], Tuple[int, int]]] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just resolution_wh?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sounds good, will change it

supervision/detection/utils.py Outdated Show resolved Hide resolved
docs/how_to/detect_small_objects.md Outdated Show resolved Hide resolved
docs/how_to/detect_small_objects.md Outdated Show resolved Hide resolved
@SkalskiP SkalskiP merged commit cd8a2be into develop May 13, 2024
9 checks passed
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.

None yet

2 participants