Coder Social home page Coder Social logo

osamproject / osam Goto Github PK

View Code? Open in Web Editor NEW
39.0 4.0 2.0 15.05 MB

Get up and running with SAM, Efficient-SAM, and other segment-anything models locally.

Home Page: https://github.com/osamproject

License: MIT License

Makefile 7.36% Python 92.64%
computer-vision deep-learning foundation-models segment-anything onnx

osam's Introduction

logo

Osam

Get up and running with segment-anything models locally.




Osam (/oʊˈsɑm/) is a tool to run open-source segment-anything models locally (inspired by Ollama).

Osam provides:

  • Segment-Anything Models - original SAM, EfficientSAM;
  • Local APIs - CLI & Python & HTTP interface;
  • Customization - Host custom vision models.

Installation

Pip

pip install osam

Quickstart

To run with EfficientSAM:

osam run efficientsam --image <image_file>

To run with YoloWorld:

osam run yoloworld --image <image_file>

Model library

Here are models that can be downloaded:

Model Parameters Size Download
SAM 100M 100M 100MB osam run sam:100m
SAM 300M 300M 300MB osam run sam:300m
SAM 600M 600M 600MB osam run sam
EfficientSAM 10M 10M 40MB osam run efficientsam:10m
EfficientSAM 30M 30M 100MB osam run efficientsam
YoloWorld XL 100M 400MB osam run yoloworld

PS. sam, efficientsam is equivalent to sam:latest, efficientsam:latest.

Usage

CLI

# Run a model with an image
osam run efficientsam --image examples/_images/dogs.jpg > output.png

# Get a JSON output
osam run efficientsam --image examples/_images/dogs.jpg --json
# {"model": "efficientsam", "mask": "..."}

# Give a prompt
osam run efficientsam --image examples/_images/dogs.jpg \
  --prompt '{"points": [[1439, 504], [1439, 1289]], "point_labels": [1, 1]}' \
  > efficientsam.png
osam run yoloworld --image examples/_images/dogs.jpg --prompt '{"text": ["dog"]}' \
  > yoloworld.png


Input and output images ('dogs.jpg', 'efficientsam.png', 'yoloworld.png').

Python

import osam.apis
import osam.types

request = osam.types.GenerateRequest(
    model="efficientsam",
    image=np.asarray(PIL.Image.open("examples/_images/dogs.jpg")),
    prompt=osam.types.Prompt(points=[[1439, 504], [1439, 1289]], point_labels=[1, 1]),
)
response = osam.apis.generate(request=request)
PIL.Image.fromarray(response.mask).save("mask.png")


Input and output images ('dogs.jpg', 'mask.png').

HTTP

# Get up the server
osam serve

# POST request
curl 127.0.0.1:11368/api/generate -X POST \
  -H "Content-Type: application/json" \
  -d "{\"model\": \"efficientsam\", \"image\": \"$(cat examples/_images/dogs.jpg | base64)\"}" \
  | jq -r .mask | base64 --decode > mask.png

osam's People

Contributors

wkentaro avatar

Stargazers

Shawn Fang avatar Leeez avatar Hanzhi Chen avatar dwadrn20192025 avatar Anagh Malik avatar  avatar Eric Franz avatar Wei.Wang avatar W. avatar  avatar  avatar Jiyee Sheng avatar  avatar Shumpei Wakabayashi avatar  avatar Wusong avatar Kirill Mazur avatar  avatar Cathrine Veum avatar Seongmoon Jeong avatar Jian Wang avatar Steven Turner avatar Yong Liu avatar Edgar avatar onedroid avatar xyxu avatar tomato avatar Lu Ming avatar tensorboy avatar Meet Shah  avatar Prajval Kumar avatar Shingo Kitagawa avatar Ibrahim Kettaneh avatar Akash Jinandra avatar  avatar  avatar  avatar Hide avatar Giseop Kim avatar

Watchers

 avatar Kostas Georgiou avatar  avatar  avatar

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.