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

feat : add SAM2CameraPredictor #124

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Gy920
Copy link

@Gy920 Gy920 commented Aug 3, 2024

Run Segment Anything Model 2 on a live video stream

@facebook-github-bot
Copy link

Hi @Gy920!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@a-krawciw
Copy link

Could you add a sample notebook showing this running on a video stream? Webcam or open cv VideoReader?

@AgentEXPL
Copy link

Run Segment Anything Model 2 on a live video stream

@Gy920 How to use this? It may be great if an example is given.

@Gy920
Copy link
Author

Gy920 commented Aug 10, 2024

I have added the notebook and instructions on how to use it.

@AgentEXPL
Copy link

I have added the notebook and instructions on how to use it.

@Gy920 In the examples of using SAM2CameraPredictor, the frame (which is in BGR?) from cap.read() may need to be converted to RGB first.

@Gy920
Copy link
Author

Gy920 commented Aug 13, 2024

@Gy920 In the examples of using SAM2CameraPredictor, the frame (which is in BGR?) from cap.read() may need to be converted to RGB first.

My bad, I didn't catch that.

@AgentEXPL
Copy link

AgentEXPL commented Aug 13, 2024

@Gy920 In the examples of using SAM2CameraPredictor, the frame (which is in BGR?) from cap.read() may need to be converted to RGB first.

My bad, I didn't catch that.

@Gy920 Never mind, it is still a great job after correction. I have checked that it works for streaming (frame-by-frame), but I found that the performance is worse than SAM2VideoPredictor.propagate_in_video() used in video_predictor_example.ipynb. . In some frames, part of the mask of the object is missing when using with SAM2CameraPredictor.track(), while it is good when using SAM2VideoPredictor.propagate_in_video(). What's the difference between them in inference?

In addition, only "add_new_points" is supported. Would it be possible to support "add_new_boxes" in SAM2CameraPredictor?

@Gy920
Copy link
Author

Gy920 commented Aug 14, 2024

@Gy920 In the examples of using SAM2CameraPredictor, the frame (which is in BGR?) from cap.read() may need to be converted to RGB first.

My bad, I didn't catch that.

@Gy920 Never mind, it is still a great job after correction. I have checked that it works for streaming (frame-by-frame), but I found that the performance is worse than SAM2VideoPredictor.propagate_in_video() used in video_predictor_example.ipynb. . In some frames, part of the mask of the object is missing when using with SAM2CameraPredictor.track(), while it is good when using SAM2VideoPredictor.propagate_in_video(). What's the difference between them in inference?

In addition, only "add_new_points" is supported. Would it be possible to support "add_new_boxes" in SAM2CameraPredictor?

I have a hunch the issue might be tied to the part simplified during implementation. That could explain the drop in tracking performance.And thanks for the heads-up on add_new_boxes, I'll definitely add that to SAM2CameraPredictor.

I'm a bit swamped at the moment, but I'll carve out some time to dig into this issue and get it sorted as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants