Skip to content

Runs in the browser · Vision

Run SlimSAM-77 in your browser

SlimSAM-77 downloads 19.8 MB over WebGPU (fp16), or 13.1 MB over WebAssembly (q8), to cut a precise mask around an object you point at entirely in the tab with Transformers.js. No install, no server.

Vision · Xenova/slimsam-77-uniform

WebGPU download
19.8 MB
fp16
WASM download
13.1 MB
q8
Parameters
9.7M
Pipeline task
custom

Reading

transformers.js has no mask-generation pipeline() task; SAM-family models are driven with the raw SamModel and AutoProcessor classes plus a click or box prompt.

The WASM build downloads smaller here: 13.1 MB (q8) against 19.8 MB (fp16) for WebGPU. The CPU-fallback quant compresses tighter than the GPU pick for this model.

Will it run in your browser?

Live check this browser

Checking for WebGPU support…

All measured variants

Quant Download size
Variant Size
q8 WASM pick 13.1 MB
fp16 WebGPU pick 19.8 MB
fp32 38.0 MB

Sizes measured from the HuggingFace API file tree for Xenova/slimsam-77-uniform, not estimated.

Use it with Transformers.js

import { SamModel, AutoProcessor, RawImage } from "@huggingface/transformers";

const model = await SamModel.from_pretrained("Xenova/slimsam-77-uniform", {
  device: "webgpu",
  dtype: "fp16", // use "q8" for the WASM build
});
const processor = await AutoProcessor.from_pretrained("Xenova/slimsam-77-uniform");

const image = await RawImage.read("https://your-image-url.jpg");
const input_points = [[[340, 250]]]; // one (x, y) click point on the object to mask
const inputs = await processor(image, { input_points });
const outputs = await model(inputs);

const masks = await processor.post_process_masks(
  outputs.pred_masks,
  inputs.original_sizes,
  inputs.reshaped_input_sizes,
);

Requires npm install @huggingface/transformers (or the CDN build). This model needs the lower-level API shown above, not pipeline() (see the Reading panel above).

Sources

Same job, different size

FAQ

WebGPU or WASM for SlimSAM-77, in practice?

Chrome, Edge, and Safari 26+ run the WebGPU build (fp16) on the GPU. Firefox has WebGPU on Windows and Apple Silicon Macs but not everywhere yet. Any browser without a WebGPU adapter falls back automatically to the WebAssembly build (q8) on CPU: same model, slower to load, slower to run.

What does fp16 mean for SlimSAM-77?

The WebGPU build here uses fp16: 16-bit floating point (half precision): smaller than fp32 with effectively no quality loss. The WASM fallback uses q8: 8-bit integers: about a quarter the size of fp32, with a smaller quality trade than 4-bit.

Sizes measured 2026-08-01 from the HuggingFace API. Last validated 2026-08-03. See all browser models or the methodology.