Update README.md
Browse files
README.md
CHANGED
@@ -5,4 +5,34 @@ pipeline_tag: image-to-text
|
|
5 |
|
6 |
https://huggingface.co/vikp/texify2 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/texify2 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/texify2`.
|
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/texify2');
|
22 |
+
|
23 |
+
// Generate LaTeX from image
|
24 |
+
const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/latex.png';
|
25 |
+
const latex = await texify(image, { max_new_tokens: 384 });
|
26 |
+
console.log(latex);
|
27 |
+
// [{ generated_text: "The potential $V_i$ of cell $\\mathcal{C}_i$ centred at position $\\mathbf{r}_i$ is related to the surface charge densities $\\sigma_j$ of cells $\\mathcal{C}_j$ $j\\in[1,N]$ through the superposition principle as: $$V_i\\,=\\,\\sum_{j=0}^{N}\\,\\frac{\\sigma_j}{4\\pi\\varepsilon_0}\\,\\int_{\\mathcal{C}_j}\\frac{1}{\\|\\mathbf{r}_i-\\mathbf{r}'\\|}\\mathrm{d}^2\\mathbf{r}'\\,=\\,\\sum_{j=0}^{N}\\,Q_{ij}\\,\\sigma_j,$$ where the integral over the surface of cell $\\mathcal{C}_j$ only depends on $\\mathcal{C}_j$ shape and on the relative position of the target point $\\mathbf{r}_i$ with respect to $\\mathcal{C}_j$ location, as $\\sigma_j$ is assumed constant over the whole surface of cell $\\mathcal{C}_j$." }]
|
28 |
+
```
|
29 |
+
|
30 |
+
| Input image | Visualized output |
|
31 |
+
|--------|--------|
|
32 |
+
| ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/9UNWPwjFM-dRVf6m1gYJV.png) | ![image/png](https://cdn-uploads.huggingface.co/production/uploads/61b253b7ac5ecaae3d1efe0c/BK4wkPTqqvlTYeTPeEXTh.png) |
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
---
|
37 |
+
|
38 |
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`).
|