casia-iva-lab / fastsam

Fast Segment Anything

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

Run casia-iva-lab/fastsam with an API

Use one of our client libraries to get started quickly.

Set the REPLICATE_API_TOKEN environment variable

export REPLICATE_API_TOKEN=<paste-your-token-here>

Learn more about authentication

Install Replicate’s Node.js client library

npm install replicate
Learn more about setup

Run casia-iva-lab/fastsam using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.

import Replicate from "replicate";
const replicate = new Replicate();

const input = {
    iou: 0.9,
    conf: 0.4,
    input_image: "https://replicate.delivery/pbxt/J45o004GBhb0mvUJgqQlaMM7lmHkdcOF5e1FV2yFFXttNbCH/download.jpeg",
    withContours: true
};

const output = await replicate.run("casia-iva-lab/fastsam:371aeee1ce0c5efd25bbef7a4527ec9e59188b963ebae1eeb851ddc145685c17", { input });

import { writeFile } from "node:fs/promises";
await writeFile("output.png", output);
//=> output.png written to disk
Learn more