Xenova HF staff commited on
Commit
9141dfc
·
verified ·
1 Parent(s): 41e7d75

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -0
README.md CHANGED
@@ -5,4 +5,32 @@ pipeline_tag: image-to-text
5
 
6
  https://huggingface.co/vikp/texify with ONNX weights to be compatible with Transformers.js.
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  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`).
 
5
 
6
  https://huggingface.co/vikp/texify with ONNX weights to be compatible with Transformers.js.
7
 
8
+ ## Usage (Transformers.js)
9
+
10
+ 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:
11
+ ```bash
12
+ npm i @xenova/transformers
13
+ ```
14
+
15
+ **Example:** Image-to-text w/ `Xenova/texify`.
16
+
17
+ ```js
18
+ import { pipeline } from '@xenova/transformers';
19
+
20
+ // Create an image-to-text pipeline
21
+ const texify = await pipeline('image-to-text', 'Xenova/texify');
22
+
23
+ // Generate LaTeX from image
24
+ const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/latex2.png';
25
+ const latex = await texify(image, { max_new_tokens: 384 });
26
+ console.log(latex);
27
+ // [{ generated_text: "$$ |\\ \\frac{1}{x}=\\frac{1}{c}|=|\\ \\frac{c-x}{xc}|=\\frac{1}{|x|}\\cdot\\frac{1}{|c|}\\cdot|x-c|$$\n\nThe factor $$ \\frac{1}{|x|}$$ is not good if its near 0." }]
28
+ ```
29
+
30
+ | Input image | Visualized output |
31
+ |--------|--------|
32
+ | ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/2wuLARy79CfVxqOLgrhDd.png) | ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/chMw_jp7StOEhS0yOdL94.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`).