Xenova HF Staff commited on
Commit
7663b1e
·
verified ·
1 Parent(s): a8d321a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -1
README.md CHANGED
@@ -6,4 +6,25 @@ pipeline_tag: image-segmentation
6
  library_name: transformers.js
7
  tags:
8
  - background-removal
9
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  library_name: transformers.js
7
  tags:
8
  - background-removal
9
+ ---
10
+
11
+
12
+ ## Usage (Transformers.js)
13
+
14
+ 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:
15
+ ```bash
16
+ npm i @huggingface/transformers
17
+ ```
18
+
19
+ **Example**: Remove background of an image
20
+
21
+ ```js
22
+ import { pipeline } from '@huggingface/transformers';
23
+
24
+ const segmenter = await pipeline('background-removal', 'onnx-community/ormbg-ONNX');
25
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/woman-with-afro_medium.jpg';
26
+ const output = await segmenter(url);
27
+ output[0].save('mask.png');
28
+ // You can also use `output[0].toCanvas()` or `await output[0].toBlob()` if you would like to access the output without saving.
29
+ ```
30
+