Skip to content

Runs in the browser · Vision

Run SAM 2.1 Hiera Tiny in your browser

SAM 2.1 Hiera Tiny downloads 32.1 MB over WebGPU (q4f16), or 59.1 MB over WebAssembly (uint8), to cut a precise mask around an object you point at entirely in the tab with Transformers.js. No install, no server.

Vision · onnx-community/sam2.1-hiera-tiny-ONNX

WebGPU download
32.1 MB
q4f16
WASM download
59.1 MB
uint8
Parameters
38.96M
Pipeline task
custom

Reading

Same as SlimSAM: transformers.js has no mask-generation pipeline() task. SAM 2 is a distinct architecture from SAM 1, so it uses the Sam2Model and Sam2Processor classes (not SamModel/SamProcessor) with a point or box prompt.

0.82 MB/M params against a 1.73 MB/M vision median: light for its parameter count.

The quant ladder spans 4.6x: 32.1 MB (q4f16) to 148.4 MB (fp32).

Will it run in your browser?

Live check this browser

Checking for WebGPU support…

All measured variants

Quant Download size
Variant Size
q4f16 WebGPU pick 32.1 MB
bnb4 47.3 MB
q4 49.1 MB
uint8 WASM pick 59.1 MB
fp16 74.4 MB
q8 118.2 MB
fp32 148.4 MB

Sizes measured from the HuggingFace API file tree for onnx-community/sam2.1-hiera-tiny-ONNX, not estimated.

Use it with Transformers.js

import { Sam2Model, Sam2Processor, RawImage } from "@huggingface/transformers";

const model = await Sam2Model.from_pretrained("onnx-community/sam2.1-hiera-tiny-ONNX", {
  device: "webgpu",
  dtype: "q4f16", // use "uint8" for the WASM build
});
const processor = await Sam2Processor.from_pretrained("onnx-community/sam2.1-hiera-tiny-ONNX");

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 SAM 2.1 Hiera Tiny, in practice?

Chrome, Edge, and Safari 26+ run the WebGPU build (q4f16) 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 (uint8) on CPU: same model, slower to load, slower to run.

What does q4f16 mean for SAM 2.1 Hiera Tiny?

The WebGPU build here uses q4f16: 4-bit weights with some layers kept at 16-bit for stability: WebGPU's usual smallest clean build. The WASM fallback uses uint8: 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.