MathScribe-OCR is a full-stack system for converting images of printed mathematical expressions into structured LaTeX code.
The project combines a Pix2TeX-based OCR backend with an interactive web interface for uploading mathematical expressions, generating LaTeX transcriptions, and previewing the resulting output.
Mathematical expressions contain complex spatial relationships such as fractions, superscripts, integrals, matrices, and operator alignment that cannot be handled effectively through basic character-level OCR.
MathScribe-OCR explores a structured image-to-LaTeX approach designed to:
- Recognize printed mathematical expressions
- Convert mathematical notation into LaTeX
- Preserve the structural relationships between symbols
- Provide an interface for reviewing and displaying generated results
The system consists of two main components:
Built with React, Vite, and Tailwind CSS.
The interface supports:
- Mathematical expression image upload
- Generated LaTeX display
- Rendered formula preview
- Interactive result handling
Built with FastAPI and a mathematical OCR model.
The backend handles:
- Image processing
- OCR inference
- Mathematical expression transcription
- LaTeX generation
- API communication with the frontend
The backend uses Pix2TeX (LaTeX-OCR), an open-source image-to-LaTeX model designed for mathematical expression recognition.
Model reference:
https://github.com/lukas-blecher/LaTeX-OCR
- The user uploads an image containing a printed mathematical expression.
- The frontend sends the image to the backend.
- The OCR model processes the mathematical notation.
- The expression is converted into LaTeX.
- The generated result is returned to the interface for display and review.
Frontend
- React
- Vite
- Tailwind CSS
- TypeScript
Backend
- Python
- FastAPI
- Pix2TeX / LaTeX-OCR
AI / Computer Vision
- Mathematical OCR
- Image-to-LaTeX
- Deep Learning
- Computer Vision
MathScribe-OCR1/
│
├── frontend/
├── Backend/
├── README.md
└── .gitignore
Both the backend and frontend must be running for the complete system to work.
Navigate to the backend directory:
cd BackendInstall the required dependencies:
pip install -r requirements.txtIf compatibility issues occur with NumPy 2.x:
pip uninstall numpy -y
pip install "numpy<2"
pip install -r requirements.txtStart the backend:
python server.pyNavigate to the frontend directory:
cd frontendInstall dependencies:
npm installStart the development server:
npm run devThe frontend will then be available locally.
MathScribe-OCR was developed as a team project by:
- Maram Moshabbab Al Romman
- Lama Muidh Alsulami
- Rimas Yasir Allehaibi
- Layan Munwer Almoqati
- Lama Mousa Alzahrani