Giter VIP home page Giter VIP logo

sam-at-home's Introduction

sam-at-home

A gradio interface to explore capabilities of Meta AI's Segment Anything Model (SAM).

Me: Mom, can we have SAM?
Mom: No there is SAM at home.
SAM at home:

Automatic Mask Generator Interface

Tool to interact with the SamAutomaticMaskGenerator interface. Specify parameters to control the automatic generation. Optionally extract transparent images of each detected segment for saving.

Segmentation of Sam the cat using Sam the model

Segmentation of Sam the cat using Sam the model

Predict Interface (experimental)

There is also minor support for foreground and background keypoints on the image to guide the prediction. This is done on a best effort basis by using the sketch-color canvas of gradio, trying to translate brush strokes into keypoints and bounding boxes. For the latter this is only supported for one bounding box currently. Has a few performance issues right now with the canvas being slow/fixed to a small size, and anti-aliasing of brush strokes causing edge cases in the box detection algorithm. This should hopefully improve in the future as gradio adds UI components for bounding boxes/keypoints.

Guided Prediction Interface

Setup

  1. Set up virtual environment using the script ./firstTimeSetup.sh, or with whichever virtual environment tool you prefer.
  2. Activate virtual environment source venv/bin/activate
  3. Download models (see below)
  4. Run UI: gradio app.py or make run
  5. Load UI in browser, usually on localhost:7860

Downloading Models

Models can be downloaded using the download_models.py script. By default gets the vit_h model, with the option to download all to the models folder. Alternatively you can fetch them directly from the official repository and manually place them there.

usage: Model downloader for the Segment Anything Models [-h] [--model {all,vit_h,vit_b,vit_l}]

optional arguments:
  -h, --help            show this help message and exit
  --model {all,vit_h,vit_b,vit_l}

Citations

@article{kirillov2023segany,
  title={Segment Anything},
  author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C. and Lo, Wan-Yen and Doll{\'a}r, Piotr and Girshick, Ross},
  journal={arXiv:2304.02643},
  year={2023}

sam-at-home's People

Contributors

dogeplusplus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sam-at-home's Issues

Slow Speed Running

Thanks for sharing your nice work!
I tried the project and successfully run in the browser. However, it takes quite a long time to segment a image. GPU(RTX 3090) is used.
So I wonder if there was something wrong.
image

It seems like it's not running on the GPU?

Nice job!
By the way! In my Windows environment, I used 'python app.py' instead of 'gradio app.py' to avoid the '[Errno 10048] error while attempting to bind on address ('127.0.0.1', 7860):' problem.
However, it takes 100 seconds to finish one picture on my PC with high CPU usage. Can it run on the GPU?"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.