Xenova HF staff commited on
Commit
107c946
·
verified ·
1 Parent(s): df04afc

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -0
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers.js
3
+ ---
4
+
5
+ ## Usage (Transformers.js)
6
+
7
+ 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:
8
+ ```bash
9
+ npm i @huggingface/transformers
10
+ ```
11
+
12
+ **Example:** Semantic segmentation with `onnx-community/sapiens-seg-0.3b`.
13
+
14
+ ```js
15
+ import { pipeline } from '@huggingface/transformers';
16
+
17
+ const segmenter = await pipeline('image-segmentation', 'onnx-community/sapiens-seg-0.3b');
18
+
19
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/ryan-gosling.jpg';
20
+ const output = await segmenter(url);
21
+ console.log(output)
22
+ // [
23
+ // {
24
+ // score: null,
25
+ // label: 'Background',
26
+ // mask: RawImage { ... }
27
+ // },
28
+ // {
29
+ // score: null,
30
+ // label: 'Apparel',
31
+ // mask: RawImage { ... }
32
+ // },
33
+ // ...
34
+ // ]
35
+ ```
36
+
37
+ You can visualize the outputs with:
38
+ ```js
39
+ for (const l of output) {
40
+ l.mask.save(`${l.label}.png`);
41
+ }
42
+ ```