A comprehensive Streamlit-based PDF analysis tool with advanced AI capabilities
π Quick Start β’ π Documentation β’ βοΈ Configuration β’ π€ Contributing
The JSL Visual Document Analyzer is a powerful, AI-driven document processing application that transforms PDF documents into structured, searchable content. Built with Streamlit and powered by multiple advanced processing backends, it offers unparalleled flexibility and accuracy in document analysis.
- β‘ Multi-Engine Processing: Choose the best processor for your specific needs
- π― High Accuracy: Advanced AI models for superior text extraction
- π° Cost Effective: CPU-optimized option requires no API keys
- π§ Developer Friendly: Clean APIs and extensible architecture
- π Enterprise Ready: Robust caching, error handling, and monitoring
| Engine | Best For | API Required | Speed | Accuracy |
|---|---|---|---|---|
| CPU Optimized | General documents, cost-effective | β No | β‘ Fast | βββ |
| GPU Optimized (VLM) | Complex layouts, highest quality | β OpenRouter | π Slower | βββββ |
| PDF to Markdown | Clean formatting, academic docs | β OpenAI | π Medium | ββββ |
| Schema Support | Structured data, forms, invoices | β OpenAI/OpenRouter | π Medium | ββββ |
- Smart Text Extraction: Maintains document structure and formatting
- Advanced Table Detection: Automatically identifies and extracts tables in markdown format
- Layout Understanding: Preserves document hierarchy and organization
- Multi-Modal Analysis: Combines visual and textual understanding for superior results
- OCR Processing: Advanced optical character recognition with high accuracy
- Image Processing: High-quality page image generation and analysis
- Intelligent Caching: Automatic result caching with TTL management (saves time and API costs)
- Real-time Progress: Live processing status with ETA estimates
- Multiple Export Formats: Markdown, Text, HTML, and more
- Print Optimization: Built-in print-ready document generation
- Batch Processing: Handle multiple documents efficiently
- Error Recovery: Robust error handling and recovery mechanisms
- Python: 3.8 or higher
- Memory: 4GB RAM minimum (8GB recommended for large documents)
- Storage: 1GB free space for cache and temporary files
- Internet: Required for API-based processors
- Clone the repository:
git clone <repository-url>
cd jsl-visual-doc-analyzer- Create virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Set up environment variables:
Create a
.envfile in the project root:
# OpenRouter API (for GPU processing)
OPENROUTER_API_KEY=your_openrouter_api_key_here
OPENROUTER_MODEL=meta-llama/llama-3.2-90b-vision-instruct
# OpenAI API (for PDF to Markdown Converter and Schema Support)
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_DEFAULT_MODEL=gpt-4o
# Optional: Cache settings
CACHE_TTL_HOURS=2
MAX_FILE_SIZE_MB=25- Run the application:
streamlit run app.py- Access the application:
Open your browser and navigate to
http://localhost:8501
Select the optimal processor for your use case:
β
No API key required
β
Fast processing
β
Good for general documents
β
Cost-effective
β Limited accuracy for complex layouts
β
Highest accuracy
β
Excellent for complex documents
β
Advanced visual understanding
β Requires OpenRouter API key
β Slower processing
β API costs apply
β
Clean markdown output
β
Great for academic documents
β
Preserves formatting
β Requires OpenAI API key
β API costs apply
β
Structured data extraction
β
Custom JSON schemas
β
Perfect for forms/invoices
β Requires API key
β More complex setup
Choose your preferred input method:
- Click "Upload Files" in the sidebar
- Drag and drop your PDF (max 25MB)
- Processing starts automatically
- Place PDF files in
data/input/folder - Click "Storage" in the sidebar
- Select file and click "Process"
- Progress Bar: Shows real-time processing status
- ETA Estimates: Approximate completion time
- Status Messages: Detailed processing steps
- Error Handling: Clear error messages if issues occur
Navigate through four comprehensive tabs:
- Beautifully formatted document display
- Ready for reading and sharing
- Download as markdown
- Print-optimized layout
- Editable text area with extracted content
- Copy and modify as needed
- Full document text
- Page-by-page breakdown
- Processing metrics
- Quality assessment
- Table detection results
- Plain text output
- Character and word counts
- Raw text for further processing
Available actions from any tab:
- Download: Multiple formats (MD, TXT, HTML)
- Print: Optimized for paper output
- Copy: Direct clipboard integration
- Cache: Automatic saving for future access
| Variable | Description | Default | Required For |
|---|---|---|---|
OPENROUTER_API_KEY |
OpenRouter API authentication | - | GPU Optimized |
OPENROUTER_MODEL |
VLM model identifier | llama-3.2-90b-vision-instruct |
GPU Optimized |
OPENAI_API_KEY |
OpenAI API authentication | - | PDF to Markdown, Schema |
OPENAI_DEFAULT_MODEL |
OpenAI model identifier | gpt-4o |
PDF to Markdown, Schema |
CACHE_TTL_HOURS |
Cache expiration time | 2 |
All processors |
MAX_FILE_SIZE_MB |
Maximum upload size | 25 |
All processors |
- Use CPU Optimized processor
- Enable aggressive caching
- Process during off-peak hours (for API-based processors)
- Use GPU Optimized (VLM)
- Enable detailed analysis
- Review results in Document Analysis tab
- Start with CPU Optimized
- Use caching aggressively
- Monitor API usage in your provider dashboard
jsl-visual-doc-analyzer/
βββ app.py # Main Streamlit application entry point
βββ src/ # Core application logic
β βββ config.py # Configuration and environment management
β βββ models.py # Pydantic data models and schemas
β βββ processors.py # Document processing backends
β βββ utils.py # Utility functions and helpers
βββ data/ # Data storage and cache
β βββ input/ # Input PDFs (for storage mode)
β βββ output/ # Processed results and cache
βββ markpdfdown/ # PDF to Markdown processor module
βββ sparrow/ # Schema Support processor module
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ README.md # This documentation
# Problem: Dependencies fail to install
# Solution: Upgrade pip and use virtual environment
pip install --upgrade pip
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt| Error | Cause | Solution |
|---|---|---|
| "No processors available" | Missing dependencies | Run pip install -r requirements.txt |
| "File too large" | File exceeds 25MB limit | Compress PDF or split document |
| "API key invalid" | Incorrect/expired API key | Verify API key in the .env file |
| "Processing timeout" | Large file/slow network | Use CPU processor or smaller files |
- Slow processing: Try CPU Optimized processor first
- High memory usage: Close other applications, use smaller files
- API rate limits: Enable caching, spread out processing
- Check logs: Look for error messages in the Streamlit interface
- Verify setup: Ensure all requirements are installed
- Test with small files: Validate setup with simple documents
- Check API status: Verify your API provider's service status
- Local Processing: CPU Optimized mode processes documents entirely locally
- API Security: API keys are stored securely in environment variables
- Data Retention: Cached files are automatically cleaned based on TTL settings
- No Persistent Storage: Documents are not permanently stored on our servers
We welcome contributions from the community!
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
# Clone your fork
git clone https://github.com/yourusername/jsl-visual-doc-analyzer.git
cd jsl-visual-doc-analyzer
# Install development dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt # If available
# Run tests
python -m pytest tests/ # If tests are available
# Start development server
streamlit run app.py- Follow Python PEP 8 style guidelines
- Add tests for new features
- Update documentation for new functionality
- Ensure backwards compatibility
- Batch Processing: Process multiple files simultaneously
- API Endpoints: REST API for programmatic access
- Cloud Integration: AWS S3, Google Drive, Dropbox support
- Advanced OCR: Support for handwritten text recognition
- Custom Models: Integration with custom-trained models
- Collaborative Features: Multi-user document review
- v3.0: Multi-processor architecture, improved caching
- v2.0: GPU optimization, Schema support
- v1.0: Initial release with CPU processing
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- π Documentation: Start with this README
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π§ Email: support@johnsnowlabs.com
For enterprise customers, we offer:
- Priority technical support
- Custom integrations
- Training and consultation
- SLA-backed response times
Contact us at enterprise@johnsnowlabs.com
John Snow Labs is the AI company for healthcare and life sciences, providing state-of-the-art AI platforms and solutions. We specialize in natural language processing, computer vision, and machine learning technologies.
Learn more: johnsnowlabs.com
β Star this repository if you find it helpful!
Made with β€οΈ by the John Snow Labs team
Report Bug β’ Request Feature β’ Documentation
