SAM (interactive segmentation)
SAM (Segment Anything) turns point prompts into polygon annotations.
Install
pip install "oneopen-ml-studio[sam]"
pip install git+https://github.com/facebookresearch/segment-anything.git
Note
[sam] installs PyTorch stack only. The segment-anything package is separate.
Checkpoint
Place a Meta SAM checkpoint under your models directory (default ~/.oneopen/models/):
File |
Size / quality |
|---|---|
|
Smaller / faster (commonly used default) |
|
Larger |
|
Largest |
Download checkpoints from the Segment Anything repository.
Usage
Open the annotator with SAM enabled in the UI.
Select a class.
Click positive / negative points on the object.
Accept the resulting polygon (stored as
source=sam).
API
POST /api/projects/{project_id}/auto-annotate/sam
Content-Type: application/json
{
"image_id": 1,
"class_id": 2,
"points": [[0.4, 0.5], [0.42, 0.55]],
"labels": [1, 1]
}
points are normalized [x, y]. labels use 1 for foreground and 0 for background (SAM convention).
Troubleshooting
Symptom |
Fix |
|---|---|
Import / module errors |
Install |
Checkpoint not found |
Put |
Very slow |
Use ViT-B on GPU; CPU is much slower |