Update README.md
Browse files
README.md
CHANGED
@@ -11,4 +11,26 @@ tags:
|
|
11 |
|
12 |
https://huggingface.co/naver-clova-ix/donut-base-finetuned-docvqa with ONNX weights to be compatible with Transformers.js.
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
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`).
|
|
|
11 |
|
12 |
https://huggingface.co/naver-clova-ix/donut-base-finetuned-docvqa with ONNX weights to be compatible with Transformers.js.
|
13 |
|
14 |
+
|
15 |
+
## Usage (Transformers.js)
|
16 |
+
|
17 |
+
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:
|
18 |
+
```bash
|
19 |
+
npm i @huggingface/transformers
|
20 |
+
```
|
21 |
+
|
22 |
+
**Example:** Answer questions about a document with `Xenova/donut-base-finetuned-docvqa`.
|
23 |
+
```js
|
24 |
+
import { pipeline } from '@huggingface/transformers';
|
25 |
+
|
26 |
+
// Create a document question answering pipeline
|
27 |
+
const qa_pipeline = await pipeline('document-question-answering', 'Xenova/donut-base-finetuned-docvqa');
|
28 |
+
|
29 |
+
// Generate an answer for a given image and question
|
30 |
+
const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/invoice.png';
|
31 |
+
const question = 'What is the invoice number?';
|
32 |
+
const output = await qa_pipeline(image, question);
|
33 |
+
// [{ answer: 'us-001' }]
|
34 |
+
```
|
35 |
+
|
36 |
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`).
|