-
Notifications
You must be signed in to change notification settings - Fork 116
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
Sam2 multi polygons #593
Sam2 multi polygons #593
Conversation
…nto sam2-multi-polygons
@PawelPeczek-Roboflow can you take a look at this? in particular, wondering if what I did here is ok -- not totally allowed by the types but I am not sure if constructing the full workflow image type here is overkill when the function needs just the height/width of the image |
What'd happen if we did a positive point at the centerpoint of the image instead? My guess is in a lot of images that'd produce a much better result given the most important object is often centered. |
@yeldarby to be clear, not a point is a special padding label, not a negative poitn I'd rather let the user decide to put a positive point in the middle of the image if they want it, otherwise let sam figure out what it should segment (even tho those results tend to be bad) |
I understand. But defaults are powerful. The special point doesn’t seem like it’d ever be a better default than the center point would be (just like a null set doesn’t seem better than the special point). Agree that almost always the user should be giving a prompt anyway, but the case we’re considering here is what we should do when they don’t. |
hmm, I would think it'd be better on images where the object in focus isn't in the center of the image as for the null set, I mean -- theoretically it should produce the same output as adding in a random point and labeling it as not a point, but for some reason the prompt encoder seems to work better with this input. |
@PawelPeczek-Roboflow tests are passing now |
I think it'd be similar, right? (bad in both cases since the -1 point and the center point both wouldn't be signaling to highlight the salient object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please add those small adjustments
tests/workflows/integration_tests/execution/test_workflow_with_sam2.py
Outdated
Show resolved
Hide resolved
inference/core/workflows/core_steps/models/foundation/segment_anything2/v1.py
Show resolved
Hide resolved
…nto sam2-multi-polygons
@PawelPeczek-Roboflow your comments have been addressed! |
Description
BREAKING CHANGE: changes format of sam2response
Allow inference to output multiple polygons from cv2.findContours
Also adds
not-a-point
at [0, 0] to empty prompts because sam2 performs better:The below shows unprompted sam2 with different settings.
Before this pr:
After adding multiple masks to return:
After adding multiple masks with dummy
not-a-point
Type of change
Please delete options that are not relevant.
How has this change been tested, please provide a testcase or example of how you tested the change?
Staging
Any specific deployment considerations
n/a
Docs