Get up and running vision foundational models locally.
Project description
Osam
Get up and running vision foundational models locally.
Osam (/oʊˈsɑm/) is a tool to run open source vision foundational models locally, built inspired by Ollama.
Osam gives you:
- Visual foundational models - Segment-Anything Model, Efficient-SAM, etc;
- Local APIs - CLI & Python & HTTP interface;
- Customization - Host custom vision models.
Installation
pip install osam
Usage
CLI
# Run a model with an image
osam run efficient-sam:25m --image examples/_images/dogs.jpg > output.jpg
# Get a JSON output
osam run efficient-sam:25m --image examples/_images/dogs.jpg --json
# {"model": "efficient-sam:25m", "mask": "..."}
# Give a prompt
osam run efficient-sam:25m --image examples/_images/dogs.jpg \
--prompt '{"points": [[1439, 504], [1439, 1289]], "point_labels": [1, 1]}' > output.jpg
Input and output images ('dogs.jpg', 'output.jpg').
Python
import osam.apis
import osam.types
request = osam.types.GenerateRequest(
model="efficient-sam:25m",
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.jpg")
Input and output images ('dogs.jpg', 'mask.jpg').
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\": \"efficient-sam:25m\", \"image\": \"$(cat examples/_images/dogs.jpg | base64)\"}" \
| jq -r .mask | base64 --decode > mask.jpg
License
MIT
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.1.0.tar.gz.
File metadata
- Download URL: osam-0.1.0.tar.gz
- Upload date:
- Size: 5.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad1e164583258e37829d61f3f60ec8322c47b37813eefefbee3148af413f70b6
|
|
| MD5 |
ede00a701c8f23c3552f45cd2fcbe513
|
|
| BLAKE2b-256 |
12e2c67b26137137317f9535b68c197d47fe79dceddb03f3c7d36f96f3f2e178
|
File details
Details for the file osam-0.1.0-py3-none-any.whl.
File metadata
- Download URL: osam-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58444710e4ea0dfb190d95f879e2de14be1d341d932090bcd372fd9edf8eabf6
|
|
| MD5 |
dcd7b59c4493ac580c33f2455ec30c6c
|
|
| BLAKE2b-256 |
cff146290dc6af818139aaa14926f8ffe4d0ba043a4c3170fb53b215a9e2cd10
|