Xenova HF staff commited on
Commit
2018389
1 Parent(s): 762f7d7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md CHANGED
@@ -4,4 +4,38 @@ library_name: transformers.js
4
 
5
  https://huggingface.co/PekingU/rtdetr_r50vd with ONNX weights to be compatible with Transformers.js.
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  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`).
 
4
 
5
  https://huggingface.co/PekingU/rtdetr_r50vd with ONNX weights to be compatible with Transformers.js.
6
 
7
+ # Usage (Transformers.js)
8
+
9
+ > [!IMPORTANT]
10
+ > NOTE: RT-DETR support is experimental and requires you to install Transformers.js [v3](https://github.com/xenova/transformers.js/tree/v3) from source.
11
+
12
+ If you haven't already, you can install the [Transformers.js](https://huggingface.co/docs/transformers.js) JavaScript library from [GitHub](https://github.com/xenova/transformers.js/tree/v3) using:
13
+ ```bash
14
+ npm install xenova/transformers.js#v3
15
+ ```
16
+
17
+ **Example:** Perform object-detection with `onnx-community/rtdetr_r50vd`.
18
+
19
+ ```js
20
+ import { pipeline } from '@xenova/transformers';
21
+
22
+ const detector = await pipeline('object-detection', 'onnx-community/rtdetr_r50vd');
23
+
24
+ const img = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
25
+ const output = await detector(img, { threshold: 0.9 });
26
+ // [{
27
+ // score: 0.9720445871353149,
28
+ // label: 'cat',
29
+ // box: { xmin: 14, ymin: 54, xmax: 319, ymax: 472 }
30
+ // },
31
+ // ...
32
+ // {
33
+ // score: 0.9795005917549133,
34
+ // label: 'sofa',
35
+ // box: { xmin: 0, ymin: 0, xmax: 640, ymax: 472 }
36
+ // }]
37
+ ```
38
+
39
+ ---
40
+
41
  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`).