CoolFace
Apppublic

davanstrien/ocr-time-capsule

sourceHugging Faceupdated 11mo agoView on Hugging Face
30likes
App README

OCR Time Capsule πŸ“¦

A fast, modern web interface for exploring and comparing OCR text improvements in HuggingFace datasets. Browse through pre-processed OCR improvements to see how AI models enhance historical document transcriptions.

OCR Time Capsule

Features

  • β€”Fast Navigation: Browse through large OCR datasets with keyboard shortcuts (J/K or arrow keys)
  • β€”Side-by-Side Comparison: View original OCR and improved text simultaneously
  • β€”Advanced Diff Visualization: Character, word, or line-level differences with color highlighting
  • β€”No Backend Required: Direct integration with HuggingFace Dataset Viewer API
  • β€”Responsive Design: Works seamlessly on desktop and mobile devices
  • β€”Dark Mode: Easy on the eyes for extended reading sessions
  • β€”URL Sharing: Share specific dataset samples with direct links

Quick Start

Option 1: Local Development

  1. 1.Clone or download this directory
  2. 2.Serve the files using any static web server:
bash
# Using Python
python -m http.server 8000

# Using Node.js
npx serve .

# Using PHP
php -S localhost:8000
  1. 1.Open http://localhost:8000 in your browser

Option 2: GitHub Pages

  1. 1.Push this directory to a GitHub repository
  2. 2.Enable GitHub Pages in repository settings
  3. 3.Access via https://[username].github.io/[repo-name]/

Option 3: Direct File Access

Simply open index.html in a modern web browser. Note: Some features may be limited due to CORS restrictions.

Usage

Loading a Dataset

  1. 1.Enter a HuggingFace dataset ID (e.g., davanstrien/exams-ocr)
  2. 2.Click "Load" or press Enter
  3. 3.The explorer will automatically detect text columns

Navigation

  • β€”Next: Press J or β†’ arrow key
  • β€”Previous: Press K or ← arrow key
  • β€”Switch Views: Press 1 (comparison), 2 (diff), or 3 (improved only)

Supported Column Names

The explorer automatically detects these column patterns:

Original OCR: text, ocr, original_text, ground_truth Improved OCR: markdown, new_ocr, corrected_text, vlm_ocr

Technical Details

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Browser UI    │────▢│ HF Dataset Viewer APIβ”‚
β”‚  (Alpine.js)    β”‚     β”‚ (datasets-server)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Local Cache    β”‚
β”‚  (JavaScript)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

API Integration

Uses the HuggingFace Dataset Viewer API:

  • β€”Base URL: https://datasets-server.huggingface.co
  • β€”No authentication required for public datasets
  • β€”Automatic handling of image URL expiration
  • β€”Smart batching for efficient data loading

Performance Optimizations

  • β€”Batch Loading: Fetches 100 rows at a time
  • β€”Smart Caching: Reduces API calls
  • β€”Lazy Loading: Only loads visible content
  • β€”URL Refresh: Automatically refreshes expired image URLs

Customization

Adding New Column Patterns

Edit js/dataset-api.js and update the detectColumns method:

javascript
if (!originalTextColumn && ['your_column_name'].includes(name)) {
    originalTextColumn = name;
}

Styling

The UI uses Tailwind CSS. Modify styles in:

  • β€”css/styles.css for custom styles
  • β€”Tailwind classes directly in index.html

Keyboard Shortcuts

Add new shortcuts in js/app.js:

javascript
case 'your_key':
    // Your action here
    break;

Browser Support

  • β€”Chrome/Edge: Full support
  • β€”Firefox: Full support
  • β€”Safari: Full support (14+)
  • β€”Mobile browsers: Full support with touch navigation

Limitations

  • β€”Maximum 100 rows per API request
  • β€”Image URLs expire after ~1 hour
  • β€”No authentication support for private datasets (yet)
  • β€”Read-only interface (no editing capabilities)

Future Enhancements

  • β€”[ ] Export functionality for improved texts
  • β€”[ ] Batch processing capabilities
  • β€”[ ] Search within dataset
  • β€”[ ] Bookmarking system
  • β€”[ ] Authentication for private datasets
  • β€”[ ] Confidence scores visualization
  • β€”[ ] Multi-dataset comparison

Troubleshooting

"Dataset viewer is not available"

  • β€”Check if the dataset exists on HuggingFace
  • β€”Ensure the dataset has viewer enabled
  • β€”Try a known working dataset like davanstrien/exams-ocr

Images not loading

  • β€”Image URLs expire after ~1 hour
  • β€”The app automatically refreshes URLs on error
  • β€”Check browser console for detailed errors

Slow loading

  • β€”Large datasets may take time for initial load
  • β€”Consider using datasets with pre-computed statistics
  • β€”Check your internet connection

Contributing

This is a standalone tool designed for OCR exploration. Feel free to fork and customize for your needs!

License

MIT License - Use freely for any purpose

Related Projects