Xenova HF staff commited on
Commit
0d96fba
1 Parent(s): 3311027

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +52 -0
README.md CHANGED
@@ -5,4 +5,56 @@ library_name: transformers.js
5
 
6
  https://huggingface.co/hustvl/yolos-tiny with ONNX weights to be compatible with Transformers.js.
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).
 
5
 
6
  https://huggingface.co/hustvl/yolos-tiny with ONNX weights to be compatible with Transformers.js.
7
 
8
+ ## Usage (Transformers.js)
9
+
10
+ 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:
11
+ ```bash
12
+ npm i @huggingface/transformers
13
+ ```
14
+
15
+ **Example:** Perform object detection with `Xenova/yolos-tiny`.
16
+
17
+ ```js
18
+ import { pipeline } from "@huggingface/transformers";
19
+
20
+ const detector = await pipeline("object-detection", "Xenova/yolos-tiny");
21
+
22
+ const image = "https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg";
23
+ const output = await detector(image, { threshold: 0.9 });
24
+ console.log(output);
25
+ ```
26
+
27
+ <details>
28
+
29
+ <summary>Example output</summary>
30
+
31
+ ```
32
+ [
33
+ {
34
+ score: 0.9921281933784485,
35
+ label: "remote",
36
+ box: { xmin: 32, ymin: 78, xmax: 185, ymax: 117 },
37
+ },
38
+ {
39
+ score: 0.9884883165359497,
40
+ label: "remote",
41
+ box: { xmin: 324, ymin: 82, xmax: 376, ymax: 191 },
42
+ },
43
+ {
44
+ score: 0.9197800159454346,
45
+ label: "cat",
46
+ box: { xmin: 5, ymin: 56, xmax: 321, ymax: 469 },
47
+ },
48
+ {
49
+ score: 0.9300552606582642,
50
+ label: "cat",
51
+ box: { xmin: 332, ymin: 25, xmax: 638, ymax: 369 },
52
+ },
53
+ ]
54
+ ```
55
+
56
+ </details>
57
+
58
+ ---
59
+
60
  Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using [🤗 Optimum](https://huggingface.co/docs/optimum/index) and structuring your repo like this one (with ONNX weights located in a subfolder named `onnx`).