Xenova HF staff commited on
Commit
23ae239
1 Parent(s): f7daddf

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +30 -0
README.md CHANGED
@@ -8,4 +8,34 @@ pipeline_tag: image-to-text
8
 
9
  https://huggingface.co/facebook/nougat-base with ONNX weights to be compatible with Transformers.js.
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  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`).
 
8
 
9
  https://huggingface.co/facebook/nougat-base with ONNX weights to be compatible with Transformers.js.
10
 
11
+
12
+ ## Usage (Transformers.js)
13
+
14
+ 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:
15
+ ```bash
16
+ npm i @xenova/transformers
17
+ ```
18
+
19
+ You can then use the model to convert images of scientific PDFs into markdown like this:
20
+
21
+ ```js
22
+ import { pipeline } from '@xenova/transformers';
23
+
24
+ // Create an image-to-text pipeline
25
+ const pipe = await pipeline('image-to-text', 'Xenova/nougat-base');
26
+
27
+ // Generate markdown
28
+ const url = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/nougat_paper.png';
29
+ const output = await pipe(url, {
30
+ min_length: 1,
31
+ max_new_tokens: 40,
32
+ bad_words_ids: [[pipe.tokenizer.unk_token_id]],
33
+ });
34
+ console.log(output);
35
+ // [{ generated_text: "# Nougat: Neural Optical Understanding for Academic Documents\n\n Lukas Blecher\n\nCorrespondence to: liblecher@meta.com\n\nGuillem Cucurull" }]
36
+ ```
37
+
38
+
39
+ ---
40
+
41
  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`).