File size: 2,281 Bytes
4cdcf4e
874b44c
4cdcf4e
59c48d8
4cdcf4e
 
 
 
daaf7c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4cdcf4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
base_model: vikp/texify2
library_name: transformers.js
pipeline_tag: image-to-text
---

https://huggingface.co/vikp/texify2 with ONNX weights to be compatible with Transformers.js.

## Usage (Transformers.js)

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:
```bash
npm i @xenova/transformers
```

**Example:** Image-to-text w/ `Xenova/texify2`.

```js
import { pipeline } from '@xenova/transformers';

// Create an image-to-text pipeline
const texify = await pipeline('image-to-text', 'Xenova/texify2');

// Generate LaTeX from image
const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/latex.png';
const latex = await texify(image, { max_new_tokens: 384 });
console.log(latex);
// [{ 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$." }]
```

| Input image | Visualized output |
|--------|--------|
| ![image/png](/static-proxy?url=https%3A%2F%2Fcdn-uploads.huggingface.co%2Fproduction%2Fuploads%2F61b253b7ac5ecaae3d1efe0c%2F9UNWPwjFM-dRVf6m1gYJV.png%3C%2Fspan%3E) | ![image/png](/static-proxy?url=https%3A%2F%2Fcdn-uploads.huggingface.co%2Fproduction%2Fuploads%2F61b253b7ac5ecaae3d1efe0c%2FBK4wkPTqqvlTYeTPeEXTh.png%3C%2Fspan%3E) |



---

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`).