mcikalmerdeka/vlms-ocr-playground
3
VLMs OCR Playground
A unified Gradio-based platform for comparing and using multiple state-of-the-art Vision-Language OCR models. Deploy easily to Hugging Face Spaces.
Supported Models
- DeepSeek-OCR-2 - Document to markdown with layout detection and PDF support
- GLM-OCR - Specialized recognition for text, formulas, and tables
- PaddleOCR-VL-1.5 - Full-page document parsing with layout detection
Project Structure
.
├── main.py # Entry point
├── requirements.txt # Dependencies
├── src/ # Source code
│ ├── config.py # Model configurations
│ ├── interface.py # Gradio interface
│ ├── models/ # Model implementations
│ └── utils/ # Utilities
└── examples/ # Sample imagesSetup
Option 1: Using pip
pip install -r requirements.txt
python main.pyOption 2: Using uv (Recommended for faster installs)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -r requirements.txt
python main.pyOption 3: Using conda
conda create -n ocr python=3.10
conda activate ocr
pip install -r requirements.txt
python main.pyTesting Without Heavy Dependencies
You can test the UI structure without downloading models:
# Test imports only
python test_imports.py
# Test UI creation (requires gradio only)
pip install gradio
python -c "from interface import create_interface; demo = create_interface()"Usage
- Select a model from the dropdown
- Upload an image or PDF (DeepSeek only)
- Choose a task
- Click Process
- View results in tabs (Text, Markdown, Visualization, Crops, Raw)
Adding New Models
To add a new model:
- Create model class in
src/models/ - Register in
src/models/__init__.py - Add config in
src/config.py
See src/models/base.py for the interface.
Troubleshooting
Dependency Conflicts
If you see errors about tokenizers or transformers version conflicts:
- The requirements.txt uses flexible version ranges to avoid conflicts
- Remove
uv.lockorpoetry.lockif present and reinstall - Use
pip install -r requirements.txt --force-reinstallif needed
Flash Attention Not Available
The models will automatically fall back to standard attention if flash-attn is not installed. This is normal and won't affect functionality.
Out of Memory
If you run out of GPU memory:
- Run on CPU (slower but works): The models will automatically use CPU if GPU is not available
- Process smaller images
- Use one model at a time
Environment Variables
PADDLEOCR_API_URL: API endpoint for PaddleOCR (optional)PADDLEOCR_TOKEN: Authentication token for PaddleOCR (optional)
License
This project combines multiple open-source OCR models. Please refer to individual model licenses.
