Xenova HF Staff commited on
Commit
37122d8
·
verified ·
1 Parent(s): 156288b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +57 -0
README.md CHANGED
@@ -5,4 +5,61 @@ library_name: transformers.js
5
 
6
  https://huggingface.co/PekingU/rtdetr_r18vd_coco_o365 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/PekingU/rtdetr_r18vd_coco_o365 with ONNX weights to be compatible with Transformers.js.
7
 
8
+
9
+ ## Usage (Transformers.js)
10
+
11
+ 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:
12
+ ```bash
13
+ npm i @huggingface/transformers
14
+ ```
15
+
16
+ **Example:** Perform object-detection with `onnx-community/rtdetr_r18vd_coco_o365`.
17
+
18
+ ```js
19
+ import { pipeline } from '@huggingface/transformers';
20
+
21
+ const detector = await pipeline('object-detection', 'onnx-community/rtdetr_r18vd_coco_o365');
22
+
23
+ const img = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
24
+ const output = await detector(img, { threshold: 0.8 });
25
+ ```
26
+
27
+ <details>
28
+
29
+ <summary>See example output</summary>
30
+
31
+ ```js
32
+ [
33
+ {
34
+ score: 0.9812611937522888,
35
+ label: 'cat',
36
+ box: { xmin: 10, ymin: 55, xmax: 316, ymax: 471 }
37
+ },
38
+ {
39
+ score: 0.9653043746948242,
40
+ label: 'remote',
41
+ box: { xmin: 40, ymin: 73, xmax: 175, ymax: 117 }
42
+ },
43
+ {
44
+ score: 0.9768251776695251,
45
+ label: 'cat',
46
+ box: { xmin: 344, ymin: 25, xmax: 640, ymax: 372 }
47
+ },
48
+ {
49
+ score: 0.8878865242004395,
50
+ label: 'remote',
51
+ box: { xmin: 333, ymin: 76, xmax: 370, ymax: 187 }
52
+ },
53
+ {
54
+ score: 0.9277128577232361,
55
+ label: 'sofa',
56
+ box: { xmin: 0, ymin: -1, xmax: 640, ymax: 478 }
57
+ }
58
+ ]
59
+ ```
60
+
61
+ </details>
62
+
63
+ ---
64
+
65
  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`).