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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAM model doesn't always get the border pixels #6250

Closed
davodogster opened this issue Jun 6, 2023 · 4 comments · Fixed by #6275
Closed

SAM model doesn't always get the border pixels #6250

davodogster opened this issue Jun 6, 2023 · 4 comments · Fixed by #6275
Assignees
Labels
bug Something isn't working

Comments

@davodogster
Copy link

Hi I'm running SAM on CVAT.ai free version and often it won't segment the border pixels even if I add point prompts for them.

image
image

Also, does CVAT.ai run SAM on the GPU or CPU? We are considering purchasing the Cloud Pro version for our organisation.

Thank you, Sam

@bsekachev bsekachev added the bug Something isn't working label Jun 7, 2023
@bsekachev
Copy link
Member

@davodogster

CVAT.ai runs SAM on GPU.

@bsekachev bsekachev self-assigned this Jun 7, 2023
@davodogster
Copy link
Author

Thanks! @bsekachev and do you know why SAM doesn't segment the pixels along the border of the image? Sometimes it misses the top/bottom borders and other times the left/right as shown in the images above.

@bsekachev
Copy link
Member

So, I have two ideas here.

  1. Apparantly part of reasons related to roundings issues between integers and floats, low and high resolution images. I tried to optimize some operations in ONNX decoder in this PR Accelerated SAM decoder, fixed serverless for EXIF rotated images #6275 and I believe it works a little bit better. Some issues with border pixels disappeared.
  2. But not all the issues disappeared. The neural network itself does not guarantee returning masks where points are located.
    Even unchanged by other operations output from the decoder has negative values on the top left pixel (where marker is located BTW):
image

Also, here you can see, that on the same image, another element can be fully covered by mask on border pixels:
image

Finally on the latest screenshot we have two images with the same size, but different content obviously (the right one picture is just filled by blue color). You can see how the right side of the right image easily covered by mask. At the same time right side of the left image hardly ever can be covered.

image

bsekachev added a commit that referenced this issue Jun 13, 2023
)

<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->
Removed extra interpolation layer

### Motivation and context
Fixed #6250

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [x] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [ ] I have added tests to cover my changes
- [x] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
@davodogster
Copy link
Author

@bsekachev Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants