Xenova HF staff commited on
Commit
32a56aa
1 Parent(s): e52ee5f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -0
README.md CHANGED
@@ -4,4 +4,43 @@ library_name: "transformers.js"
4
 
5
  https://huggingface.co/facebook/detr-resnet-50 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/facebook/detr-resnet-50 with ONNX weights to be compatible with Transformers.js.
6
 
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/@xenova/transformers) using:
11
+ ```bash
12
+ npm i @xenova/transformers
13
+ ```
14
+
15
+ **Example:** Perform object-detection with `Xenova/detr-resnet-50`.
16
+
17
+ ```js
18
+ import { pipeline } from '@xenova/transformers';
19
+
20
+ let detector = await pipeline('object-detection', 'Xenova/detr-resnet-50');
21
+
22
+ let img = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
23
+ let output = await detector(img, { threshold: 0.9 });
24
+ // [{
25
+ // "score": 0.9976370930671692,
26
+ // "label": "remote",
27
+ // "box": { "xmin": 31, "ymin": 68, "xmax": 190, "ymax": 118 }
28
+ // },
29
+ // ...
30
+ // {
31
+ // "score": 0.9984092116355896,
32
+ // "label": "cat",
33
+ // "box": { "xmin": 331, "ymin": 19, "xmax": 649, "ymax": 371 }
34
+ // }]
35
+ ```
36
+
37
+ ## Demo
38
+
39
+ Test it out [here](https://huggingface.co/spaces/static-templates/transformers.js), or [create](https://huggingface.co/new-space?template=static-templates%2Ftransformers.js) your own object-detection demo with 1 click!
40
+
41
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/Tum2wSnygrcAJUIDk_bCg.png)
42
+
43
+ ---
44
+
45
+
46
  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`).