Xenova HF Staff commited on
Commit
a643398
·
verified ·
1 Parent(s): 28e1bbf

Update README.md

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