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

Added support for Facebook''s Segment Anything #431

Merged
merged 9 commits into from
Apr 20, 2023
Merged

Added support for Facebook''s Segment Anything #431

merged 9 commits into from
Apr 20, 2023

Conversation

Flippchen
Copy link
Contributor

@Flippchen Flippchen commented Apr 20, 2023

This Pull Request brings a significant update to our project by introducing the SamSession class, specifically designed to seamlessly integrate with Facebook's advanced Segment Anything model (https://github.com/facebookresearch/segment-anything).

The key highlights of this PR include:

SamSession Class: A dedicated class tailored for the Segment Anything model, allowing users to take full advantage of its capabilities.
Edited Remove Function: The addition of a new parameter to the remove function, enabling the input of target points.
Customized Prediction Function: A separate prediction function, distinct from the other classes, to optimize the usage of the Segment Anything model.
Multi-Model Download Support: An improved download function that now supports downloads for multiple models.

@danielgatis Suggestions for improvement are welcome. I will also add the CI support soon.

You can try it with the following code:

from pathlib import Path
from rembg import remove, new_session

here = Path(__file__).parent.resolve()

model_name = "sam"
session = new_session(model_name)
image = Image.open(here / ".." / "examples" / "car-2.jpg")

input_point = np.array([[600,350]])
input_label = np.array([1])

image = remove(image,session=session, input_point=input_point, input_label=input_label)

image.show()

image

@danielgatis
Copy link
Owner

wow! it is an amazing contribution thank you so much!

@danielgatis danielgatis merged commit 1e31133 into danielgatis:main Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants