Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCR Evaluation Project

This project provides a FastAPI-based API for evaluating the performance of multiple OCR engines (Tesseract, Nanonets, and EasyOCR) on images, particularly for Scandinavian medical records. It calculates various metrics such as character accuracy, word accuracy, sequence accuracy, edit distance score, and BLEU score.

Project Structure

ocr_evaluation_project/
├── ocr_evaluation/
│   ├── __init__.py
│   ├── models/
│   │   ├── ocr_metrics.py
│   ├── evaluators/
│   │   ├── base_evaluator.py
│   │   ├── tesseract_evaluator.py
│   │   ├── nanonets_evaluator.py
│   │   ├── easyocr_evaluator.py
│   ├── utils/
│   │   ├── image_processing.py
│   │   ├── text_processing.py
│   │   ├── metrics_calculation.py
│   ├── api/
│   │   ├── main.py
│   │   ├── responses.py
├── README.md
├── requirements.txt
├── setup.py

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd ocr_evaluation_project
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Install the package:

    pip install -e .

Usage

Run the FastAPI server:

uvicorn ocr_evaluation.api.main:app --host 0.0.0.0 --port 8000

Access the API documentation at http://localhost:8000/docs.

Endpoints

  • POST /ocr/tesseract: Evaluate images using Tesseract OCR.
  • POST /ocr/nanonets: Evaluate images using Nanonets OCR.
  • POST /ocr/easyocr: Evaluate images using EasyOCR.

Each endpoint accepts a list of images and corresponding ground truth texts, returning metrics including character accuracy, word accuracy, and composite score.

Requirements

See requirements.txt for a complete list of dependencies. Key dependencies include:

  • OpenCV
  • Pytesseract
  • EasyOCR
  • Transformers
  • FastAPI
  • Torch
  • Levenshtein

Run the python backend as

uvicorn api.main:app --host 0.0.0.0 --port 8080

then send a curl request as

curl -X POST "http://localhost:8080/ocr/evaluate_csv" -F "csv_file=@data/ocr_data.csv" {"detail":"400: Image not found: /images/CD3428B3-FB1B-48FD-A6BD-AD6500A37BA9_page3_det27_breathing.png"}(ocr_venv) administrator@vlad:~/Desktop/LLM_STUFF/OCR_Models/project$ curl -X POST "http://localhost:8080/ocr/evaluate_csv" -F "csv_file=@data/ocr_data.csv"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages