Sam3 Image Rle

Sam3 Image Rle

Playground

Try it on WavespeedAI!

SAM 3 RLE is a unified foundation model for promptable image segmentation using text, points, or boxes to detect and segment objects. Returns RLE (Run-Length Encoding) encoded masks for efficient storage and processing. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.

Features

SAM3 Image Segmentation RLE

SAM3 Image Segmentation RLE is an advanced image segmentation model based on Meta’s Segment Anything Model 3. It returns segmentation masks in RLE (Run-Length Encoding) format — a compact, program-friendly output ideal for API integration, automated pipelines, and machine learning workflows.


Why Choose This?

  • RLE output format Returns compact Run-Length Encoded mask data instead of image files — smaller payload, faster transfer.

  • Multiple prompt types Segment objects using text prompts, point prompts, box prompts, or any combination.

  • API-optimized Designed for programmatic use, batch processing, and automated workflows.

  • COCO-compatible RLE format is directly compatible with COCO dataset tools and annotation pipelines.

  • Prompt Enhancer Built-in tool to automatically improve your text prompts for better results.

  • Ultra-affordable Just $0.005 per image for professional-quality segmentation.


Parameters

ParameterRequiredDescription
imageYesSource image to segment (upload or URL)
promptNo*Text description of the object to segment
point_promptsNo*Point coordinates to identify the target object
box_promptsNo*Bounding box coordinates to identify the target object
apply_maskNoOverlay the segmentation mask on the original image

*At least one prompt type (text, boxes, or points) must be provided.


How to Use

  1. Upload your image — drag and drop or paste a URL.
  2. Add prompts — provide at least one of the following:
    • Text prompt — describe the object to segment (e.g., “the man”, “the dog”).
    • Point prompts — click ”+ Add Item” to add point coordinates.
    • Box prompts — click ”+ Add Item” to add bounding box coordinates.
  3. Enable apply_mask (optional) — check to include mask overlay data.
  4. Run — submit and receive RLE-encoded segmentation data.

Output Format

The model returns RLE (Run-Length Encoding) data in JSON format:

{
  "rle": "146301 3 147834 11 149368 14 150903 16 ..."
}

Decoding RLE in Python

from pycocotools import mask as mask_utils
 
rle_data = {"counts": "146301 3 147834 11 ...", "size": [height, width]}
binary_mask = mask_utils.decode(rle_data)  # Returns numpy array

Pricing

ItemCost
Per image$0.005

Simple flat-rate pricing regardless of image size or prompt complexity.


Best Use Cases

  • ML Data Annotation — Generate segmentation masks for training datasets in COCO format.
  • Automated Pipelines — Integrate segmentation into batch processing workflows.
  • API Integration — Compact output for efficient API responses.
  • Computer Vision — Programmatic mask processing for CV applications.
  • Background Removal at Scale — Extract masks for automated image processing.

Pro Tips

  • Use this model when you need programmatic access to mask data.
  • Use SAM3 Image if you need direct image output.
  • RLE format is compatible with pycocotools for easy decoding.
  • Combine multiple prompt types for more accurate segmentation.
  • Text prompts work best for common objects with clear descriptions.

Notes

  • At least one prompt type must be provided (text, points, or boxes).
  • Output is RLE-encoded JSON, not an image file.
  • Use pycocotools or similar libraries to decode RLE data.
  • Ideal for automated and batch processing workflows.

  • SAM3 Image — Same segmentation with direct image output.
  • Bria RMBG — Background removal model.

Authentication

For authentication details, please refer to the Authentication Guide.

API Endpoints

Submit Task & Query Result


# Submit the task
curl --location --request POST "https://api.wavespeed.ai/api/v3/wavespeed-ai/sam3-image-rle" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${WAVESPEED_API_KEY}" \
--data-raw '{
    "point_prompts": [],
    "box_prompts": [],
    "apply_mask": true,
    "enable_sync_mode": false
}'

# Get the result
curl --location --request GET "https://api.wavespeed.ai/api/v3/predictions/${requestId}/result" \
--header "Authorization: Bearer ${WAVESPEED_API_KEY}"

Parameters

Task Submission Parameters

Request Parameters

ParameterTypeRequiredDefaultRangeDescription
imagestringYes-URL of the image to segment and analyze
promptstringNo-Text description to guide which objects or regions to segment
point_promptsarrayNo[]-List of point coordinates to mark specific locations for segmentation (foreground or background)
box_promptsarrayNo[]-List of bounding boxes to define rectangular regions for segmentation
apply_maskbooleanNotrue-Whether to overlay the segmentation mask on the original image
enable_sync_modebooleanNofalse-If set to true, the function will wait for the result to be generated and uploaded before returning the response. It allows you to get the result directly in the response. This property is only available through the API.

Response Parameters

ParameterTypeDescription
codeintegerHTTP status code (e.g., 200 for success)
messagestringStatus message (e.g., “success”)
data.idstringUnique identifier for the prediction, Task Id
data.modelstringModel ID used for the prediction
data.outputsarrayArray of URLs to the generated content (empty when status is not completed)
data.urlsobjectObject containing related API endpoints
data.urls.getstringURL to retrieve the prediction result
data.has_nsfw_contentsarrayArray of boolean values indicating NSFW detection for each output
data.statusstringStatus of the task: created, processing, completed, or failed
data.created_atstringISO timestamp of when the request was created (e.g., “2023-04-01T12:34:56.789Z”)
data.errorstringError message (empty if no error occurred)
data.timingsobjectObject containing timing details
data.timings.inferenceintegerInference time in milliseconds

Result Request Parameters

ParameterTypeRequiredDefaultDescription
idstringYes-Task ID

Result Response Parameters

ParameterTypeDescription
codeintegerHTTP status code (e.g., 200 for success)
messagestringStatus message (e.g., “success”)
dataobjectThe prediction data object containing all details
data.idstringUnique identifier for the prediction, the ID of the prediction to get
data.modelstringModel ID used for the prediction
data.outputsobjectArray of outputs containing RLE encoded masks (empty when status is not completed).
data.urlsobjectObject containing related API endpoints
data.urls.getstringURL to retrieve the prediction result
data.statusstringStatus of the task: created, processing, completed, or failed
data.created_atstringISO timestamp of when the request was created (e.g., “2023-04-01T12:34:56.789Z”)
data.errorstringError message (empty if no error occurred)
data.timingsobjectObject containing timing details
data.timings.inferenceintegerInference time in milliseconds
© 2025 WaveSpeedAI. All rights reserved.