meta
/
sam-2
SAM 2: Segment Anything v2 (for Images)
Prediction
meta/sam-2:fe97b453ModelIDep2njwkpmnrgm0ch11etka38bwStatusSucceededSourceAPIHardwareA40 (Large)Total durationCreatedInput
{ "image": "https://replicate.delivery/pbxt/LMbGi83qiV3QXR9fqDIzTl0P23ZWU560z1nVDtgl0paCcyYs/cars.jpg", "use_m2m": true, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 }
npm install replicate
Set theREPLICATE_API_TOKEN
environment variableexport REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Import and set up the clientimport Replicate from "replicate"; const replicate = new Replicate({ auth: process.env.REPLICATE_API_TOKEN, });
Run meta/sam-2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run( "meta/sam-2:fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83", { input: { image: "https://replicate.delivery/pbxt/LMbGi83qiV3QXR9fqDIzTl0P23ZWU560z1nVDtgl0paCcyYs/cars.jpg", use_m2m: true, points_per_side: 32, pred_iou_thresh: 0.88, stability_score_thresh: 0.95 } } ); console.log(output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
Set theREPLICATE_API_TOKEN
environment variableexport REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Import the clientimport replicate
Run meta/sam-2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run( "meta/sam-2:fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83", input={ "image": "https://replicate.delivery/pbxt/LMbGi83qiV3QXR9fqDIzTl0P23ZWU560z1nVDtgl0paCcyYs/cars.jpg", "use_m2m": True, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 } ) print(output)
To learn more, take a look at the guide on getting started with Python.
Set theREPLICATE_API_TOKEN
environment variableexport REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Run meta/sam-2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ -H "Content-Type: application/json" \ -H "Prefer: wait" \ -d $'{ "version": "fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83", "input": { "image": "https://replicate.delivery/pbxt/LMbGi83qiV3QXR9fqDIzTl0P23ZWU560z1nVDtgl0paCcyYs/cars.jpg", "use_m2m": true, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 } }' \ https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Output
{ "completed_at": "2024-07-31T10:37:50.278514Z", "created_at": "2024-07-31T10:37:08.645000Z", "data_removed": false, "error": null, "id": "ep2njwkpmnrgm0ch11etka38bw", "input": { "image": "https://replicate.delivery/pbxt/LMbGi83qiV3QXR9fqDIzTl0P23ZWU560z1nVDtgl0paCcyYs/cars.jpg", "use_m2m": true, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 }, "logs": null, "metrics": { "predict_time": 21.914778485, "total_time": 41.633514 }, "output": { "combined_mask": "https://replicate.delivery/pbxt/PhfVJubSlhzqZqxiZKbyQCmtmjP6rws91HtwQzO5jBk4LeNTA/combined_mask.png", "individual_masks": [ "https://replicate.delivery/pbxt/DAMeQcIlnRSDO6RTIkey7trNX3j2DtTx3FQegWVcWeZKfivZC/mask_0.png", "https://replicate.delivery/pbxt/xc7O4VYKmyLeDqIfhReltaJtWZsIYcnfsS9UMOY4CShOfivZC/mask_1.png", "https://replicate.delivery/pbxt/WFfGtnyyOH2gTSDhlufECopzZu68XkdZ0w5CMy5UTOfnv4bmA/mask_2.png", "https://replicate.delivery/pbxt/KHLBzhB1GoIdChe4uvu3tO7QZrhe4urDefcnId6ydigPfivZC/mask_3.png", "https://replicate.delivery/pbxt/myZfr7p9NTWHOykkm7pUD8cZRApomzDqquJYJdaoCVn5LeNTA/mask_4.png", "https://replicate.delivery/pbxt/eIOBbg4hh7QYC6dLrfn61hvTLLgBmjTPtfCTWop5NvQpv4bmA/mask_5.png", "https://replicate.delivery/pbxt/fOZeBxDpz1tlhkblydmC5Bd2e8uhfNQWPmNNNhJQ7ZnSfivZC/mask_6.png", "https://replicate.delivery/pbxt/rpLtlLRmqZaFAxFdZOik2Pqge7nluiAEV4FKnyTvIRX6LeNTA/mask_7.png", "https://replicate.delivery/pbxt/IARwRBPniqKYM9295TSPeUdon17fotj2AoUErKSU6u00X8NTA/mask_8.png", "https://replicate.delivery/pbxt/tZQyFazldaZfG6jUTU7bAYv2wS4XWZl3FTejd6Hm1rU1X8NTA/mask_9.png", "https://replicate.delivery/pbxt/1eBwAWxD5WTXRaXGJsfBz45REvPCnExBHvnksHCUwNF1X8NTA/mask_10.png", "https://replicate.delivery/pbxt/ImswooWq6w4bGNeQU4F1VALalzD3WxL3J5fkC7rHzhX1X8NTA/mask_11.png", "https://replicate.delivery/pbxt/S01evfUYgmj13UQ52TF2cXxBgl1heLfvJEJl8rxEhzqVfivZC/mask_12.png", "https://replicate.delivery/pbxt/CQ9uM5nf8OQUf0PeAbDQzPOxI5GiYFDFMH2ggmZAeye1eFfmJA/mask_13.png", "https://replicate.delivery/pbxt/9lhv0Cc6eG2uGC67p0y3KQfegtYDamFtQWU8xfoSnM7YfivZC/mask_14.png", "https://replicate.delivery/pbxt/sgI2BPy8N345Nt8CjOpH65AhxodFTwJMZemsSfCJajv2X8NTA/mask_15.png", "https://replicate.delivery/pbxt/HaSi973aEz6ACdUXKpFgRI6ifYJH3e9e2vyu2aKuyqFsv4bmA/mask_16.png", "https://replicate.delivery/pbxt/eM3dAO2iD6Qzd6qKuhhKAeGKniaPRZs0BKsVeLGW9PJvv4bmA/mask_17.png", "https://replicate.delivery/pbxt/DZPfKY4mYMXCN64eb46BkMyQqFBAgTYu8kL7B5mTAjZ3X8NTA/mask_18.png", "https://replicate.delivery/pbxt/nBGDKOqumzJsL5XcoGlx1Fq9NyVeT7WatrUzTWQocVp7LeNTA/mask_19.png", "https://replicate.delivery/pbxt/fN4p5RfeW8eOVRPZ7mk9oeaNf4Alo66z9mv2YEN5ZQ249FfmJA/mask_20.png", "https://replicate.delivery/pbxt/3JVrxRyhab4eWCw4esfxnKfjZUYTsmFyYa9TwTdciLgjfivZC/mask_21.png", "https://replicate.delivery/pbxt/3hohGMQe6mUfRkNHclqjLlZpInbF3Le83M8sQVWl0fSjfivZC/mask_22.png", "https://replicate.delivery/pbxt/9ZXLfog4DNRCKy3pQxS3en8RI8C4SSQovxtIc4Ys1gQ4X8NTA/mask_23.png", "https://replicate.delivery/pbxt/9Lf0stUHiNzLB6EfZ2tPrNGwumuR0uJQS860b94bvDi4X8NTA/mask_24.png", "https://replicate.delivery/pbxt/dfZs8fErgkvxi0XfOw8aKvLk5GKBvWoY3aquLcRoo5wzv4bmA/mask_25.png", "https://replicate.delivery/pbxt/7L1FQiv47YJaHNCMaJLi37f5TMW2z2H2m3XsWsZk9Q78LeNTA/mask_26.png", "https://replicate.delivery/pbxt/e447UtIxXdUmXq9YnreNPujnpfdfeGYKgX6Ku7M63s2PfFfmJA/mask_27.png", "https://replicate.delivery/pbxt/1G3qphp2mFpvKZPXyt9HAdODieSmNlDLiwFRo7Eek4d5X8NTA/mask_28.png", "https://replicate.delivery/pbxt/EpRmoaerZW2BT6Zg4EDVfRxtfEJPUnT1BnaMlBg3EwU1v4bmA/mask_29.png", "https://replicate.delivery/pbxt/unCFZVKBw160ElV9uhj4He7u3JqjyVH60xYf9d4arK66X8NTA/mask_30.png", "https://replicate.delivery/pbxt/bnBGLe8290yXLai2r3TJRTGgiDLGPlmHg1a2G1M9bAC9LeNTA/mask_31.png", "https://replicate.delivery/pbxt/yFkW0RfIglX9DKQflH61GKywHkDyoVLSqvse1n0tw0A1v4bmA/mask_32.png", "https://replicate.delivery/pbxt/SbrXAeDzcAwwNy7a6PavKWlfSslX27qyfa5yB6LRVg92v4bmA/mask_33.png", "https://replicate.delivery/pbxt/hVzxopNLP0qDGBxduzOJEptmHmrSIVeqQUxfChD8fgF2v4bmA/mask_34.png", "https://replicate.delivery/pbxt/uDZnysBzS9pDEFeVsUnJipMifz9dvBEg6WYUw1X7We53v4bmA/mask_35.png", "https://replicate.delivery/pbxt/bh1sfZ9L8qQTPCSK2JUNTDJvyxzjVC3VAhg9Q3CKQBm9LeNTA/mask_36.png", "https://replicate.delivery/pbxt/fZeLEdVopUvYGkNmiwEfqkt7y0hSvGqlHK4ih4Pxn2fyfivZC/mask_37.png", "https://replicate.delivery/pbxt/A9X6GvHNf1V9R65DAV369g73nPIUM0l9e2BzKfeek27jfFfmJA/mask_38.png", "https://replicate.delivery/pbxt/SvR05e7oQH2iX60adulwQfcXbGnSCaHZNQdNF1kcvdp8X8NTA/mask_39.png", "https://replicate.delivery/pbxt/uhqPd9eJhm2lOSnouFGWSJPF23UirL06UANuJ0tuqXReX8NTA/mask_40.png", "https://replicate.delivery/pbxt/CFrKeK2w5V2mRKnEz5fSg43ODC8azyzEgjrFyoUh9fk6v4bmA/mask_41.png", "https://replicate.delivery/pbxt/kbQ3u3fKpw01Dq04mFEXTaelXQ88OzkfnKiFkHoLwHm7v4bmA/mask_42.png", "https://replicate.delivery/pbxt/ix1CsX9vocYdHFE8T8MCyEwcRXqTPQNL24Bvv2C7sHWfLeNTA/mask_43.png", "https://replicate.delivery/pbxt/h2KZSr8uXFrGF9C6Cwmg9ide7AhU1sunTLedwJH9EHv9X8NTA/mask_44.png", "https://replicate.delivery/pbxt/UuIriEfrOv1XTilzSXbD2s3Gys5L8uQpInJZkmvuSCYfX8NTA/mask_45.png" ] }, "started_at": "2024-07-31T10:37:28.363736Z", "status": "succeeded", "urls": { "get": "https://api.replicate.com/v1/predictions/ep2njwkpmnrgm0ch11etka38bw", "cancel": "https://api.replicate.com/v1/predictions/ep2njwkpmnrgm0ch11etka38bw/cancel" }, "version": "fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83" }
Generated inPrediction
meta/sam-2:fe97b453ModelIDtmndkxgnshrgm0ch11rbc581qcStatusSucceededSourceWebHardwareA40 (Large)Total durationCreatedInput
{ "image": "https://replicate.delivery/pbxt/Iiuk5Wbn4LZgOckuDhVt7xYItEs46K1hBW8DTETFYUte27Aa/Screen%20Shot%202022-10-11%20at%2010.38.29%20PM.png", "use_m2m": true, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 }
npm install replicate
Set theREPLICATE_API_TOKEN
environment variableexport REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Import and set up the clientimport Replicate from "replicate"; const replicate = new Replicate({ auth: process.env.REPLICATE_API_TOKEN, });
Run meta/sam-2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run( "meta/sam-2:fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83", { input: { image: "https://replicate.delivery/pbxt/Iiuk5Wbn4LZgOckuDhVt7xYItEs46K1hBW8DTETFYUte27Aa/Screen%20Shot%202022-10-11%20at%2010.38.29%20PM.png", use_m2m: true, points_per_side: 32, pred_iou_thresh: 0.88, stability_score_thresh: 0.95 } } ); console.log(output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
Set theREPLICATE_API_TOKEN
environment variableexport REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Import the clientimport replicate
Run meta/sam-2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run( "meta/sam-2:fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83", input={ "image": "https://replicate.delivery/pbxt/Iiuk5Wbn4LZgOckuDhVt7xYItEs46K1hBW8DTETFYUte27Aa/Screen%20Shot%202022-10-11%20at%2010.38.29%20PM.png", "use_m2m": True, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 } ) print(output)
To learn more, take a look at the guide on getting started with Python.
Set theREPLICATE_API_TOKEN
environment variableexport REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Run meta/sam-2 using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ -H "Content-Type: application/json" \ -H "Prefer: wait" \ -d $'{ "version": "fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83", "input": { "image": "https://replicate.delivery/pbxt/Iiuk5Wbn4LZgOckuDhVt7xYItEs46K1hBW8DTETFYUte27Aa/Screen%20Shot%202022-10-11%20at%2010.38.29%20PM.png", "use_m2m": true, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 } }' \ https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Output
{ "completed_at": "2024-07-31T10:59:01.755968Z", "created_at": "2024-07-31T10:57:29.036000Z", "data_removed": false, "error": null, "id": "tmndkxgnshrgm0ch11rbc581qc", "input": { "image": "https://replicate.delivery/pbxt/Iiuk5Wbn4LZgOckuDhVt7xYItEs46K1hBW8DTETFYUte27Aa/Screen%20Shot%202022-10-11%20at%2010.38.29%20PM.png", "use_m2m": true, "points_per_side": 32, "pred_iou_thresh": 0.88, "stability_score_thresh": 0.95 }, "logs": null, "metrics": { "predict_time": 10.520536726, "total_time": 92.719968 }, "output": { "combined_mask": "https://replicate.delivery/pbxt/bhj0cpdiVf30OCeS9o9Z1z4QtbTfiOAw1bZ8hwcHYbWjX5bmA/combined_mask.png", "individual_masks": [ "https://replicate.delivery/pbxt/76j3Jia0f72PS6mKehiCKaS1QawtmM1Aee1nfShIsCFUeKfmJA/mask_0.png", "https://replicate.delivery/pbxt/aA2vXAVJ5fx3DCcaYgFO5kAG8G492eo7pgCtnHgmKFKyr8NTA/mask_1.png", "https://replicate.delivery/pbxt/WCmO58Mp0jLzONfAq9bdIUeexf2pxHiCCb5VNcMgfgTdeKfmJA/mask_2.png", "https://replicate.delivery/pbxt/tlJT64orpYYUP9Kwg21eAp9tN3DzmgSznO4OvmFI5dk5VeNTA/mask_3.png", "https://replicate.delivery/pbxt/xmEhtUXOQE5jAxqCH7HnPdpzcB1G1xT6BUNEUf6NdLu5VeNTA/mask_4.png", "https://replicate.delivery/pbxt/miOyc1ZruR7RJBxoL1VEwzn31S2KrsKKHYp0TPFP6a88KfmJA/mask_5.png", "https://replicate.delivery/pbxt/uYLwtMPcPu4xOpc26GkZyqLRbX9JoaY1e6AzXcli8ZI6VeNTA/mask_6.png", "https://replicate.delivery/pbxt/xGgzrHR0iRbpG1diMwwfrGc2JifVk1jrTZZyZF7eS8eRvy3MB/mask_7.png", "https://replicate.delivery/pbxt/duaTAKbsUUrvFt3xwWQrNwWjHSlOQ2M5EhJ7HrAS1cJ9KfmJA/mask_8.png", "https://replicate.delivery/pbxt/f7GZnOEvjJS8biZp42Ulkqf7rkszp4JU3aZjJrRqwmL0r8NTA/mask_9.png", "https://replicate.delivery/pbxt/MfqZYgngeVuXSESXPcYwwzO2eFFl4KhErYL9IO0TeUnWvy3MB/mask_10.png", "https://replicate.delivery/pbxt/QSanj6O7IirxBhZe2g95qrJLecfKIy8s10hCUUi3wEaqX5bmA/mask_11.png", "https://replicate.delivery/pbxt/JbX9cWJl84KmKpF11djKjuhuBx82DTmTXI2ZzIYPrzV9KfmJA/mask_12.png" ] }, "started_at": "2024-07-31T10:58:51.235431Z", "status": "succeeded", "urls": { "get": "https://api.replicate.com/v1/predictions/tmndkxgnshrgm0ch11rbc581qc", "cancel": "https://api.replicate.com/v1/predictions/tmndkxgnshrgm0ch11rbc581qc/cancel" }, "version": "fe97b453a6455861e3bac769b441ca1f1086110da7466dbb65cf1eecfd60dc83" }
Generated in
Want to make some of these yourself?
Run this model