Segment Anything Model

The Segment Anything Model (SAM) produces high quality object masks from input prompts such as points or boxes, and it can be used to generate masks for all objects in an image.

Playground

Try the model in real time below.

loading...

Click or Drag-n-Drop

PNG, JPG or GIF, Up-to 2048 x 2048 px

output image


Examples

Check out what others have created with Segment Anything Model

API

If you're looking for an API, you can choose from your desired programming language.

POST
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 import requests import base64 # Use this function to convert an image file from the filesystem to base64 def image_file_to_base64(image_path): with open(image_path, 'rb') as f: image_data = f.read() return base64.b64encode(image_data).decode('utf-8') # Use this function to fetch an image from a URL and convert it to base64 def image_url_to_base64(image_url): response = requests.get(image_url) image_data = response.content return base64.b64encode(image_data).decode('utf-8') api_key = "YOUR_API_KEY" url = "https://api.segmind.com/v1/sam-img2img" # Request payload data = { "image": image_url_to_base64("https://segmind.com/kitchen.jpg") # Or use image_file_to_base64("IMAGE_PATH") } headers = {'x-api-key': api_key} response = requests.post(url, json=data, headers=headers) print(response.content) # The response is the generated image
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing

Attributes


imageimage *

Image to Segment

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.


Pricing

Serverless Pricing

Buy credits that can be used anywhere on Segmind

$ 0.0015 /per second

Dedicated Cloud Pricing

For enterprise costs and dedicated endpoints

$ 0.0007 - $ 0.0031 /per second
FEATURES

PixelFlow allows you to use all these features

Unlock the full potential of generative AI with Segmind. Create stunning visuals and innovative designs with total creative control. Take advantage of powerful development tools to automate processes and models, elevating your creative workflow.

Segmented Creation Workflow

Gain greater control by dividing the creative process into distinct steps, refining each phase.

Customized Output

Customize at various stages, from initial generation to final adjustments, ensuring tailored creative outputs.

Layering Different Models

Integrate and utilize multiple models simultaneously, producing complex and polished creative results.

Workflow APIs

Deploy Pixelflows as APIs quickly, without server setup, ensuring scalability and efficiency.

Segment Anything Model (SAM)

The Segment Anything Model (SAM) is the latest groundbreaking AI model introduced by Meta AI. With the power to "cut out" any object from any image with just a single click, SAM is revolutionizing the world of image processing. Zero-shot capability; Unlike other models that require extensive training for each new object or image, SAM boasts of a promptable segmentation system. This means it can easily generalize to unfamiliar objects and images without the need for any additional training.

The SAM model architecture integrates a masked auto-encoder (MAE) and a Vision Transformer (ViT) to generate distinct image embeddings, typically initialized before model prompting. SAM's prompt encoding component transforms elements such as points, masks, and texts into immediate vectors, categorizing prompts into sparse or dense groups. Subsequently, SAM's mask decoder predicts segmentation masks by leveraging these embeddings, aligning them with a specific output token. Through bidirectional cross-attention, the labeled masks are processed to enhance SAM's weights, ensuring its adaptability and streamlined performance.

Advantages

  1. Zero-shot Learning: SAM can identify and segment unfamiliar objects without any prior training, making it highly versatile.

  2. Promptable System: Users can easily guide SAM using prompts, ensuring more accurate results tailored to specific needs.

  3. Speed and Efficiency: Thanks to its advanced architecture, SAM processes images rapidly, delivering results in real-time.

  4. High Precision : SAM's extensive training and hybrid architecture ensure that the segmented results are of the highest quality.

Use cases

  1. E-commerce Product Listing: Retailers can use SAM to automatically segment product images, removing backgrounds and placing products on a consistent backdrop.

  2. Photo Editing Apps: SAM can be integrated into photo editing software, allowing users to easily extract objects and create composite images.

  3. Augmented Reality (AR) Applications: SAM can help in real-time object segmentation, enabling developers to overlay virtual objects onto real-world scenes seamlessly.

  4. Medical Imaging: Healthcare professionals can use SAM to segment specific organs or anomalies in medical images, aiding in diagnosis and treatment planning.

  5. Video Production: Film and video editors can utilize SAM to segment and replace backgrounds, create special effects, or integrate CGI elements into real footage.

SAM License

The Segment Anything Model (SAM) is open source. Meta AI has released the SA-1B Dataset for research purposes and also made available the pre-trained models (approximately 2.4 GB) and associated code. All of these are licensed under the Apache 2.0, a permissive license, in line with FAIR's dedication to open research.

F.A.Q.

Frequently Asked Questions

Take creative control today and thrive.

Start building with a free account or consult an expert for your Pro or Enterprise needs. Segmind's tools empower you to transform your creative visions into reality.

Pixelflow Banner