whitphx HF Staff commited on
Commit
b5443ce
·
verified ·
1 Parent(s): c6643e1

Add/update the quantized ONNX model files and README.md for Transformers.js v3

Browse files

## Applied Quantizations

### ✅ Based on `model.onnx` *without* slimming

Files changed (1) hide show
  1. README.md +8 -10
README.md CHANGED
@@ -6,23 +6,22 @@ pipeline_tag: object-detection
6
 
7
  https://github.com/WongKinYiu/yolov9 with ONNX weights to be compatible with Transformers.js.
8
 
9
-
10
  ## Usage (Transformers.js)
11
 
12
- 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:
13
  ```bash
14
- npm i @xenova/transformers
15
  ```
16
 
17
  **Example:** Perform object-detection with `Xenova/yolov9-c`.
18
 
19
  ```js
20
- import { AutoModel, AutoProcessor, RawImage } from '@xenova/transformers';
21
 
22
  // Load model
23
  const model = await AutoModel.from_pretrained('Xenova/yolov9-c', {
24
- // quantized: false, // (Optional) Use unquantized version.
25
- })
26
 
27
  // Load processor
28
  const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
@@ -35,12 +34,12 @@ const image = await RawImage.read(url);
35
  const { pixel_values } = await processor(image);
36
 
37
  // Run object detection
38
- const { outputs } = await model({ images: pixel_values })
39
  const predictions = outputs.tolist();
40
 
41
  for (const [xmin, ymin, xmax, ymax, score, id] of predictions) {
42
- const bbox = [xmin, ymin, xmax, ymax].map(x => x.toFixed(2)).join(', ')
43
- console.log(`Found "${model.config.id2label[id]}" at [${bbox}] with score ${score.toFixed(2)}.`)
44
  }
45
  // Found "car" at [176.86, 335.53, 399.82, 418.13] with score 0.94.
46
  // Found "car" at [447.50, 378.46, 639.81, 477.57] with score 0.93.
@@ -59,5 +58,4 @@ Test it out [here](https://huggingface.co/spaces/Xenova/yolov9-web)!
59
 
60
  ---
61
 
62
-
63
  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`).
 
6
 
7
  https://github.com/WongKinYiu/yolov9 with ONNX weights to be compatible with Transformers.js.
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 `Xenova/yolov9-c`.
17
 
18
  ```js
19
+ import { AutoModel, AutoProcessor, RawImage } from '@huggingface/transformers';
20
 
21
  // Load model
22
  const model = await AutoModel.from_pretrained('Xenova/yolov9-c', {
23
+ dtype: 'fp32', // (Optional) Use unquantized version.
24
+ });
25
 
26
  // Load processor
27
  const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
 
34
  const { pixel_values } = await processor(image);
35
 
36
  // Run object detection
37
+ const { outputs } = await model({ images: pixel_values });
38
  const predictions = outputs.tolist();
39
 
40
  for (const [xmin, ymin, xmax, ymax, score, id] of predictions) {
41
+ const bbox = [xmin, ymin, xmax, ymax].map(x => x.toFixed(2)).join(', ');
42
+ console.log(`Found "${model.config.id2label[id]}" at [${bbox}] with score ${score.toFixed(2)}.`);
43
  }
44
  // Found "car" at [176.86, 335.53, 399.82, 418.13] with score 0.94.
45
  // Found "car" at [447.50, 378.46, 639.81, 477.57] with score 0.93.
 
58
 
59
  ---
60
 
 
61
  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`).