Giter Club home page Giter Club logo

tiangong-ai-latex's Introduction

Env Preparing

Setup venv:

python3.11 -m venv .venv
source .venv/bin/activate

Install requirements:

python.exe -m pip install --upgrade pip

pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install -r requirements.txt --upgrade

Test Cuda (optional):

nvidia-smi

Nougat-LaTeX-OCR

Nougat-LaTeX-based is fine-tuned from facebook/nougat-base with im2latex-100k to boost its proficiency in generating LaTeX code from images. Since the initial encoder input image size of nougat was unsuitable for equation image segments, leading to potential rescaling artifacts that degrades the generation quality of LaTeX code. To address this, Nougat-LaTeX-based adjusts the input resolution and uses an adaptive padding approach to ensure that equation image segments in the wild are resized to closely match the resolution of the training data. Download the model here ๐Ÿ‘ˆ๐Ÿป.

Uses

fine-tune on your customized dataset

  1. Prepare your dataset in this format
  2. Change config/base.yaml
  3. Run the training script
python tools/train_experiment.py --config_file config/base.yaml --phase 'train'

use it directly

use a pipeline as a high-level helper

from transformers import pipeline
pipe = pipeline("image-to-text", model="Norm/nougat-latex-base")

load model directly

from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained("Norm/nougat-latex-base")
model = AutoModel.from_pretrained("Norm/nougat-latex-base")

Check the model application information in https://huggingface.co/Norm/nougat-latex-base You can find an example in examples_for_latex folder

python examples/run_latex_ocr.py --img_path "examples/test_data/eq1.png"

tiangong-ai-latex's People

Contributors

normxu avatar fadeloo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.