Ir para o conteúdo
ModelListadosExterno
Baixar

Mediapipe Selfie Segmentation

If you haven't already, you can install the Transformers.js JavaScript library from NPM using: npm i @huggingface/transformers

TipoOtherVersãoRevision be49485Bnota

Fonte do modelo

Tipo
Other
Tamanho do arquivo
219–452 KB
Versão
vRevision be49485
Atualizado
20 de out. de 2026
Downloads
807
Fonte
Hugging Face

Descrição da fonte

Usage (Transformers.js)

If you haven't already, you can install the Transformers.js JavaScript library from NPM using:

npm i @huggingface/transformers

Example: Selfie segmentation with onnx-community/mediapipe_selfie_segmentation.

import { AutoModel, AutoProcessor, RawImage } from '@huggingface/transformers';

// Load model and processor
const model_id = 'onnx-community/mediapipe_selfie_segmentation';
const model = await AutoModel.from_pretrained(model_id, { dtype: 'fp32' });
const processor = await AutoProcessor.from_pretrained(model_id);

// Load image from URL
const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/selfie_segmentation.png';
const image = await RawImage.read(url);

// Pre-process image
const inputs = await processor(image);

// Predict alpha matte
const { alphas } = await model(inputs);

// Save output mask
const mask = await RawImage.fromTensor(alphas[0].mul(255).to('uint8')).resize(image.width, image.height);
mask.save('mask.png');

// (Optional) Apply mask to original image
const result = image.clone().putAlpha(mask);
result.save('result.png');
Input imagePredicted maskOutput image
image/pngimage/pngimage/png

Fontes

1 fonte
Hugging FacePrimárioVersão be49485c8e027524be38591817fc5cd31bd9d00e
huggingface.co/onnx-community/mediapipe_selfie_segmentation/tree/be49485c8e027524be38591817fc5cd31bd9d00e

Verificado 20 de out.

Artefatos de modelo

8 artefatos

onnx/model_bnb4.onnx

onnx · 452 KB · SHA-256 18dc7ae85006…8641 · Hugging Face

Baixar

onnx/model_fp16.onnx

onnx · 245 KB · SHA-256 3b2a53a26b6e…ea4f · Hugging Face

Baixar

onnx/model_int8.onnx

onnx · 219 KB · SHA-256 9bc3d56b0b13…5983 · Hugging Face

Baixar

onnx/model_q4.onnx

onnx · 452 KB · SHA-256 18dc7ae85006…8641 · Hugging Face

Baixar

onnx/model_q4f16.onnx

onnx · 245 KB · SHA-256 7fca30d1bbd0…d544 · Hugging Face

Baixar

onnx/model_quantized.onnx

onnx · 219 KB · SHA-256 50b5e96de9d1…1994 · Hugging Face

Baixar

onnx/model_uint8.onnx

onnx · 219 KB · SHA-256 50b5e96de9d1…1994 · Hugging Face

Baixar

onnx/model.onnx

onnx · 452 KB · SHA-256 3241ac4ad8aa…1aad · Hugging Face

Baixar

Trechos de fonte

3 trechos

--- license: apache-2.0 pipeline_tag: image-segmentation tags: - background-removal --- ## Usage (Transformers.js) If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [NPM](https://www.npmjs.com/package/@huggingface/transformers) using: ```bash npm i @huggingface/transformers ``` **Example:** Selfie segmentation with `onnx-community/mediapipe_selfie_segmentation`. ```js import { AutoModel, AutoProcessor, RawImage } from '@huggingface/transformers'; // Load model and processor const model_id = 'onnx-community/mediapipe_selfie_segmentation'; const model = await AutoModel.from_pretrained(model_id, { dtype: 'fp32' }); const processor = await AutoProcessor.from_pretrained(model_id); // Load image from URL const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/selfie_segmentation.png'; const image = await RawImage.read(url); // Pre-process image const inputs = await processor(image); // Predict alpha matte const { alphas } = await model(inputs); // Save output mask const mask = await RawImage.fromTensor(alphas[0].mul(255).to('uint8')).resize(image.width, image.height); mask.save('mask.png'); // (Optional) Apply mask to original image const result = image.clone().putAlpha(mask); result.save('result.png'); ``` | Input image | Predicted mask | Output image | | :----------:|:------------:|:------------:| | ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/NR--WRELcGKsY8c7dI7s5.png) | ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/tAsPevxCzxGank2iHXo7o.png) | ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/8RMmqdfcgr4cclN5Dv6ae.png) |

Source context: 807 downloads · 7 likes · Pipeline image-segmentation · Repo onnx-community/mediapipe_selfie_segmentation

Source context: 671 downloads · 5 likes · Pipeline image-segmentation · Repo onnx-community/mediapipe_selfie_segmentation