Saltar al contenido
ModelPublicadoExterno
Descargar

Mediapipe Selfie Segmentation

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

TipoOtherVersiónRevision be49485Bcalidad

Fuente del modelo

Tipo
Other
Tamaño del archivo
219–452 KB
Versión
vRevision be49485
Actualizado
20 oct 2026
Descargas
807
Fuente
Hugging Face

Descripción de la fuente

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

Fuentes

1 fuente
Hugging FacePrincipalVersión be49485c8e027524be38591817fc5cd31bd9d00e
huggingface.co/onnx-community/mediapipe_selfie_segmentation/tree/be49485c8e027524be38591817fc5cd31bd9d00e

Verificado 20 oct

Artefactos del modelo

8 artefactos

onnx/model_bnb4.onnx

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

Descargar

onnx/model_fp16.onnx

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

Descargar

onnx/model_int8.onnx

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

Descargar

onnx/model_q4.onnx

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

Descargar

onnx/model_q4f16.onnx

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

Descargar

onnx/model_quantized.onnx

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

Descargar

onnx/model_uint8.onnx

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

Descargar

onnx/model.onnx

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

Descargar

Extractos de fuentes

3 extractos

--- 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