pablodawson / segment-anything-automatic

SegmentAnything Model (SAM) automatic mask generator

  • Public
  • 4.1K runs
  • T4
  • GitHub
  • Paper
  • License

Input

image
*file

Input image

integer

The width to resize the image to before running inference.

Default: 1024

integer

The number of points to be sampled along one side of the image. The total number of points is points_per_side**2. If None, point_grids must provide explicit point sampling.

Default: 32

number

A filtering threshold in [0,1], using the model's predicted mask quality.

Default: 0.88

number

A filtering threshold in [0,1], using the stability of the mask under changes to the cutoff used to binarize the model's mask predictions.

Default: 0.95

number

The amount to shift the cutoff when calculated the stability score.

Default: 1

number

The box IoU cutoff used by non-maximal suppression to filter duplicate masks.

Default: 0.7

integer

If >0, mask prediction will be run again on crops of the image. Sets the number of layers to run, where each layer has 2**i_layer number of image crops

Default: 0

number

The box IoU cutoff used by non-maximal suppression to filter duplicate masks between different crops.

Default: 0.7

number

Sets the degree to which crops overlap. In the first crop layer, crops will overlap by this fraction of the image length. Later layers with more crops scale down this overlap.

Default: 0.3413333333333333

integer

The number of points-per-side sampled in layer n is scaled down by crop_n_points_downscale_factor**n.

Default: 1

integer

If >0, postprocessing will be applied to remove disconnected regions and holes in masks with area smaller than min_mask_region_area.

Default: 0

Output

output
Generated in

Run time and cost

This model costs approximately $0.0035 to run on Replicate, or 285 runs per $1, but this varies depending on your inputs. It is also open source and you can run it on your own computer with Docker.

This model runs on Nvidia T4 GPU hardware. Predictions typically complete within 16 seconds. The predict time for this model varies significantly based on the inputs.

Readme

Segment Anything

Meta AI Research, FAIR

Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick

[Paper] [Project] [Demo] [Dataset]

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. It has been trained on a dataset of 11 million images and 1.1 billion masks, and has strong zero-shot performance on a variety of segmentation tasks.

Note: I’m not the author of this model. Please refer to their official page for questions. Here I use the included “SamAutomaticMaskGenerator” to auto-generate masks.