Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make image predictor thread-safe#643

Open
adamp87 wants to merge 1 commit intofacebookresearch:main from
adamp87:stateless-img
Open

Make image predictor thread-safe #643
adamp87 wants to merge 1 commit intofacebookresearch:main from
adamp87:stateless-img

Conversation

@adamp87
Copy link

@adamp87 adamp87 commented May 6, 2025
edited
Loading

  • Problem: SAM2ImagePredictor is not thread-safe as it stores state variables after set_image() or set_image_batch(). This can be cumbersome to handle in a multi-threaded environment e.g. Web App.
  • Solution: return object by set_image(), which holds "state" variables. Pass returned object to predicts(). This makes predictor stateless.
  • Backward compatibility: store last computed object of set_image() in SAM2ImagePredictor

scriptator reacted with thumbs up emoji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /