Update README.md
Browse files
README.md
CHANGED
@@ -7,4 +7,30 @@ pipeline_tag: image-to-text
|
|
7 |
|
8 |
https://huggingface.co/microsoft/trocr-base-handwritten with ONNX weights to be compatible with Transformers.js.
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
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`).
|
|
|
7 |
|
8 |
https://huggingface.co/microsoft/trocr-base-handwritten with ONNX weights to be compatible with Transformers.js.
|
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:** Optical character recognition w/ `Xenova/trocr-base-handwritten`.
|
18 |
+
|
19 |
+
```js
|
20 |
+
import { pipeline } from '@xenova/transformers';
|
21 |
+
|
22 |
+
// Create image-to-text pipeline
|
23 |
+
const captioner = await pipeline('image-to-text', 'Xenova/trocr-base-handwritten');
|
24 |
+
|
25 |
+
// Perform optical character recognition
|
26 |
+
const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/handwriting.jpg';
|
27 |
+
const output = await captioner(image);
|
28 |
+
// [{ generated_text: 'Mr. Brown commented icily.' }]
|
29 |
+
```
|
30 |
+
|
31 |
+
|
32 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/OORjA9b3gc5pvqJssq_9M.png)
|
33 |
+
|
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`).
|