Views
No views yet
npm i @huggingface/transformersXenova/texify2.1import { pipeline } from '@huggingface/transformers';
2
3// Create an image-to-text pipeline
4const texify = await pipeline('image-to-text', 'Xenova/texify2');
5
6// Generate LaTeX from image
7const image = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/latex.png';
8const latex = await texify(image, { max_new_tokens: 384 });
9console.log(latex);
10// [{ 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 |
|---|---|
![]() | ![]() |
onnx).