Divide an image into multiple segments for applications like medical imaging, object detection, and computer vision tasks.

Quickstart

Segment an Image

Send an image to a model to generate segmentation masks.

import Bytez from "bytez.js";
import { writeFileSync } from "fs";

const client = new Bytez("YOUR_BYTEZ_KEY_HERE");
const model = client.model("sayeed99/segformer-b3-fashion");

const imgUrl = "https://ocean.si.edu/sites/default/files/styles/3_2_largest/public/2023-11/Screen_Shot_2018-04-16_at_1_42_56_PM.png.webp?itok=Icvi-ek9";

const { error, output: maskObjects } = await model.run(imgUrl);

if (error) {
  console.error("Error:", error);
} else {
  maskObjects.forEach(({ label, score, mask_png }, i) => {
    console.log({ label, score });
    const maskBuffer = Buffer.from(mask_png, "base64");
    writeFileSync(`mask-${i}.png`, maskBuffer);
  });
}

Demo