Skip to content

[Example] SAM: support box prompt #1206

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

[Example] SAM: support box prompt #1206

wants to merge 13 commits into from

Conversation

kwsp
Copy link

@kwsp kwsp commented Apr 30, 2025

Segment Anything supports points and boxes as prompts. Currently the example only supports a single point. This PR adds

  • Support for a single box
  • Support for single mask output (defaults to multi mask output)

Further work (outside the scope of this PR):

  • Support multiple points
  • Support multiple boxes
  • Support boxes and points

Copy link
Member

@ggerganov ggerganov left a comment

Choose a reason for hiding this comment

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

Thanks for the addition. Consider adding a test to ci/run.sh to exercise the new functionality.

kwsp and others added 7 commits May 4, 2025 12:21
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
@kwsp
Copy link
Author

kwsp commented May 4, 2025

@ggerganov Added a test for the 2 new features to ci/run.sh!

@kwsp
Copy link
Author

kwsp commented May 4, 2025

I added these features while porting MedSAM to ggml. MedSAM uses different preprocessing and only supports box prompt and single mask output.

Here's that repo: https://github.com/kwsp/MedSAM.cpp, linked here for reference. Since my codebases use OpenCV, I replaced the manual bilinear interpolation and sam_image_* with OpenCV, so you probably don't want that here 😜

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

Successfully merging this pull request may close these issues.

2 participants