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

SAM2 video-to-video real-time pipeline #280

Merged
merged 13 commits into from
Dec 3, 2024
Merged

Conversation

eliteprox
Copy link
Collaborator

@eliteprox eliteprox commented Nov 15, 2024

Adds segment-anything-2 support to the live-video-to-video pipeline, supporting the models facebook/sam2-hiera-tiny, facebook/sam2-hiera-small and facebook/sam2-hiera-large.

Start stream:

curl --location 'http://localhost:8937/live/video-to-video/test/start' \
--form 'source_id="testout"' \
--form 'source_type="webrtcSession"' \
--form 'query="pipeline=segment_anything_2&params={\"point_coords\": [[200,300]], \"point_labels\": [1], \"show_points\": true, \"model_id\":\"facebook/sam2-hiera-tiny\"}"'

Update model parameters:

curl --location 'http://localhost:8937/live/video-to-video/test/update' \
--header 'Content-Type: application/json' \
--data '{
    "point_coords": [[200,300]],
    "point_labels": [1],
    "show_points": false,
    "model_id": "facebook/sam2-hiera-tiny"
}
'

@eliteprox eliteprox changed the title Adds segment-anything-2 to the live-video-to-video pipeline SAM2 video-to-video real-time pipeline Nov 15, 2024
@eliteprox eliteprox force-pushed the feature/sam2-realtime branch 2 times, most recently from e7218c3 to 5bbae09 Compare November 19, 2024 23:09
@eliteprox eliteprox marked this pull request as ready for review November 20, 2024 20:40
@eliteprox eliteprox requested a review from rickstaa as a code owner November 20, 2024 20:40
@eliteprox eliteprox force-pushed the feature/sam2-realtime branch from 5bbae09 to 3792855 Compare November 21, 2024 07:18
@eliteprox eliteprox force-pushed the feature/sam2-realtime branch 2 times, most recently from 02a4fa1 to b586552 Compare December 3, 2024 00:10
@eliteprox eliteprox requested a review from pschroedl December 3, 2024 01:28
@thomshutt thomshutt requested a review from victorges December 3, 2024 11:45
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

Awesome! Only some minor nits

runner/app/live/Sam2Wrapper/wrapper.py Outdated Show resolved Hide resolved
runner/app/live/Sam2Wrapper/wrapper.py Outdated Show resolved Hide resolved
runner/app/live/Sam2Wrapper/wrapper.py Outdated Show resolved Hide resolved
runner/app/live/infer.py Outdated Show resolved Hide resolved
runner/app/live/pipelines/segment_anything_2.py Outdated Show resolved Hide resolved
runner/app/live/pipelines/segment_anything_2.py Outdated Show resolved Hide resolved
runner/app/live/pipelines/segment_anything_2.py Outdated Show resolved Hide resolved
runner/app/live/pipelines/segment_anything_2.py Outdated Show resolved Hide resolved
runner/docker/Dockerfile.live-base-segment_anything_2 Outdated Show resolved Hide resolved
runner/docker/Dockerfile.live-base-segment_anything_2 Outdated Show resolved Hide resolved
@eliteprox eliteprox force-pushed the feature/sam2-realtime branch from 9486ab7 to 6b705eb Compare December 3, 2024 19:02
@eliteprox eliteprox requested a review from victorges December 3, 2024 19:17
Copy link

@seanhanca seanhanca left a comment

Choose a reason for hiding this comment

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

in segment_anything_2.py,

def update_params function, there is no exception handling or parmas validation, before applied the change, i.e recreate a model, with new params. what if it failed.

@eliteprox
Copy link
Collaborator Author

in segment_anything_2.py,

def update_params function, there is no exception handling or parmas validation, before applied the change, i.e recreate a model, with new params. what if it failed.

Params validation is handled by Sam2LiveParams which only accepts the fields and types defined there.

Errors originating from update_params or process_frame will be handled by the PipelineProcess class which loads the pipeline using a try/catch.

update_params is also used in infer.py to update model parameters from control api requests and uses a try/catch already.

@eliteprox eliteprox merged commit d11b114 into main Dec 3, 2024
9 checks passed
@eliteprox eliteprox deleted the feature/sam2-realtime branch December 3, 2024 22:50
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.

3 participants