Skip to content

Playground Web UI using segment-anything-2 models from the Meta.

License

Notifications You must be signed in to change notification settings

DaveStuff/sam2-playground

 
 

Repository files navigation

sam2-playground

Gradio based playground web UI using facebook/segment-anything-2 models.

Online Demos

colab huggingface

Feature

<<<<<<< HEAD

  • Easy green background video by inverting mask
Green background video
green_background_example.mp4
  • Add filters to segment parts of a video with pixelated or solid color
Pixelize the girl's face
example_video.mp4
======= - Segment video for transparent background or pixelated object
Transparent background
Transparent.background.mp4
Pixelate
Pixelate.mp4
>>>>>>> de28ecaff3782f8754a9ca331be603b2f5bc1b92

<<<<<<< HEAD

  • Divide segmentation parts of the image into layers and save them as PSD files. =======
  • Segment image to divide objects into layers and save them as PSD files.

de28ecaff3782f8754a9ca331be603b2f5bc1b92

Divide clothes into layers and save as PSD file
Example_PSD

See PROMPT_GUIDE.md to see how to prompt the segmentation parts of the image.

Installation and Running

Prerequisites

To run this Web UI, you need these prerequisites. If you don't have them, please install them in the following links :

After installing FFmpeg, make sure to add the FFmpeg/bin folder to your system PATH!
And for CUDA, if you're not using an Nvidia GPU and CUDA 12.4, edit the requirements.txt to match your environment.

Option 1 : Running with Shell / Batch Scripts

There's a set of shell / batch scripts for installation and running.

  1. Download sam2-playground-portable.zip with the file corresponding to your OS and extract its contents. <<<<<<< HEAD
  2. Run install.bat or install.sh to install dependencies. (This will create a venv directory and install dependencies there.)
  3. Start WebUI with start-webui.bat or start-webui.sh
  4. To update, run update.bat or update.sh =======
  5. Run install.bat or install.sh to install dependencies. (It will create a venv directory and install dependencies there.)
  6. Start WebUI with start-webui.bat or start-webui.sh (It will run python app.py after activating the venv)
  7. To update, run update.bat or update.sh (It will run git pull origin master)

de28ecaff3782f8754a9ca331be603b2f5bc1b92

Option 2: Docker

  1. Clone the repository
git clone https://github.com/jhj0517/sam2-playground.git
  1. Build the image ( Image is about ~6 GB )
docker compose build
  1. Run the container
docker compose up
  1. Connect to localhost:7860 with your browser.

If needed, update docker-compose.yaml to match your environments.

Todo 🗓

  • Support change() API for gradio_image_prompter and automatically generate preview for video predictor

About

Playground Web UI using segment-anything-2 models from the Meta.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 94.5%
  • Jupyter Notebook 4.4%
  • Dockerfile 1.1%