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 | 94M | 100MB | osam run sam:100m |
| SAM 300M | 313M | 310MB | osam run sam:300m |
| SAM 600M | 642M | 630MB | osam run sam |
| SAM2 Tiny | 39M | 150MB | osam run sam2:tiny |
| SAM2 Small | 46M | 170MB | osam run sam2:small |
| SAM2 BasePlus | 82M | 300MB | osam run sam2 |
| SAM2 Large | 227M | 870MB | osam run sam2:large |
| SAM3 | 893M | 3.4GB | osam run sam3 |
| EfficientSAM 10M | 10M | 40MB | osam run efficientsam:10m |
| EfficientSAM 30M | 26M | 100MB | osam run efficientsam |
| YOLO-World XL | 168M | 640MB | 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
# 1. point prompt (background=0, foreground=1)
osam run efficientsam --image examples/_images/dogs.jpg \
--prompt '{"points": [[1439, 504], [1439, 1289]], "point_labels": [1, 1]}' \
> efficientsam_point.png
# 2. box prompt (lt=2, rb=3)
osam run sam2 --image examples/_images/dogs.jpg \
--prompt '{"points": [[1233, 376], [1649, 691]], "point_labels": [2, 3]}' \
> sam2_box.png
# 3. text prompt
osam run sam3 --image examples/_images/dogs.jpg --prompt '{"texts": ["dog"]}' \
> sam3_text.png
Output images: 'efficientsam_point.png', 'sam2_box.png', 'sam3_text.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file osam-0.3.1.tar.gz.
File metadata
- Download URL: osam-0.3.1.tar.gz
- Upload date:
- Size: 23.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1caacbc58d3d372c5f792698f7bb0dff370485b64d667b788b425299fed63981
|
|
| MD5 |
53cf3bd4d14b3841a93efbd92c708d16
|
|
| BLAKE2b-256 |
f605bc941d7b10f9b1223c11bafb9e0a46297a7ed6fcbc6e9cfaf197f7e88784
|
File details
Details for the file osam-0.3.1-py3-none-any.whl.
File metadata
- Download URL: osam-0.3.1-py3-none-any.whl
- Upload date:
- Size: 2.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d5faf063ca2ee12d6e1467b71ba2343aa36256c371bd901aeb7e2184f480de1
|
|
| MD5 |
5656fdb4f31e65c041e1dacabd74252a
|
|
| BLAKE2b-256 |
d890e0ffc73f92185b12467a0e72e6185cc3caaa721c7496c2529cbb3886fa5c
|