https://github.com/wkentaro/osam
Get up and running with SAM, EfficientSAM, YOLO-World, and other promptable vision models locally.
https://github.com/wkentaro/osam
computer-vision deep-learning foundation-models onnx segment-anything
Last synced: 6 months ago
JSON representation
Get up and running with SAM, EfficientSAM, YOLO-World, and other promptable vision models locally.
- Host: GitHub
- URL: https://github.com/wkentaro/osam
- Owner: wkentaro
- License: mit
- Created: 2024-01-14T12:41:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-15T11:15:32.000Z (7 months ago)
- Last Synced: 2025-04-20T07:40:58.356Z (6 months ago)
- Topics: computer-vision, deep-learning, foundation-models, onnx, segment-anything
- Language: Python
- Homepage: https://github.com/wkentaro/osam
- Size: 16.3 MB
- Stars: 52
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
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](https://github.com/ollama/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
```bash
pip install osam
```**For `osam serve`**:
```bash
pip install osam[serve]
```## Quickstart
To run with EfficientSAM:
```bash
osam run efficientsam --image
```To run with YOLO-World:
```bash
osam run yoloworld --image
```## 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` |
| 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
```bash
# 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 '{"texts": ["dog"]}' \
> yoloworld.png
```
![]()
![]()
![]()
Input and output images ('dogs.jpg', 'efficientsam.png', 'yoloworld.png').### Python
```python
import osam.apis
import osam.typesrequest = 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
```bash
# 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
```