Xenova HF staff commited on
Commit
898219b
1 Parent(s): 454b300

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -0
README.md CHANGED
@@ -6,4 +6,27 @@ tags:
6
 
7
  https://huggingface.co/microsoft/dit-base-finetuned-rvlcdip with ONNX weights to be compatible with Transformers.js.
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  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://huggingface.co/microsoft/dit-base-finetuned-rvlcdip 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/@xenova/transformers) using:
12
+ ```bash
13
+ npm i @xenova/transformers
14
+ ```
15
+
16
+ **Example:** Perform document image classification with `Xenova/dit-base-finetuned-rvlcdip`
17
+ ```js
18
+ import { pipeline } from '@xenova/transformers';
19
+
20
+ // Create an image classification pipeline
21
+ const classifier = await pipeline('image-classification', 'Xenova/dit-base-finetuned-rvlcdip');
22
+
23
+ // Classify an image
24
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/coca_cola_advertisement.png';
25
+ const output = await classifier(url);
26
+ // [{ label: 'advertisement', score: 0.9035086035728455 }]
27
+ ```
28
+ ---
29
+
30
+
31
+
32
  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`).