Get up and running vision foundational models locally.
Project description
Osam
Get up and running with promptable vision models locally.
Osam (/oʊˈsɑm/) is a tool to run open-source promptable vision models locally (inspired by Ollama).
Osam provides:
- Promptable Vision Models - Segment Anything Model (SAM), EfficientSAM, YOLO-World;
- Local APIs - CLI & Python & HTTP interface;
- Customization - Host custom vision models.
Installation
Pip
pip install osam
For osam serve
:
pip install osam[serve]
Quickstart
To run with EfficientSAM:
osam run efficientsam --image <image_file>
To run with YOLO-World:
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 |
YOLO-World 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
# pip install osam[serve] # required for `osam serve`
# 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
osam-0.2.2.tar.gz
(14.5 MB
view details)
Built Distribution
osam-0.2.2-py3-none-any.whl
(2.2 MB
view details)
File details
Details for the file osam-0.2.2.tar.gz
.
File metadata
- Download URL: osam-0.2.2.tar.gz
- Upload date:
- Size: 14.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55197fc9b872b5e4a2fa4442191b8fb7258259c20fd1883a5b9259dafdf761d2 |
|
MD5 | fe65a0ca314a03033d9464fd363f5a19 |
|
BLAKE2b-256 | d7bc638b4b7838da3335f4ff5bb4b6f063d45b22103d2a167344a2287ae01b99 |
File details
Details for the file osam-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: osam-0.2.2-py3-none-any.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d70596f65910485ab16f88868406dcba952a15c7d8deff600b65b259d9378d3d |
|
MD5 | 7685f5c388da587cfec2c35431d37a17 |
|
BLAKE2b-256 | 698310f06194103f85e4d1cb68e9119e33864905f96e8a5b7ddd1678c57cd3a8 |