2-Stage Neural Compression Pipeline
Noisy scanned document image → CNN OCR → Adaptive Huffman compression → lossless text recovery.
Two communicating Flask microservices built with PyTorch. Pre-trained weights are included. No training required to run the demo.
Repository Structure
pipeline/ ├── stage1_ocr/ ├── stage2_compression/ ├── launch.py ├── pipeline_demo.py ├── run_on_dataset.py ├── results.csv └── results_v2.csv
Dataset (for context)
This project uses: SimulatedNoisyOffice/
Used for:
- Training the denoiser
- Evaluating OCR under noisy conditions
Quick Start for Judges
Pre-trained weights are included.
1. Install dependencies
pip install -r requirements.txt
2. Run the entire system
python launch.py
That is all you need.
The script will:
- Start both microservices automatically
- Wait until they are ready
- Open a browser UI at http://localhost:5000
Press Ctrl+C to stop everything.
How to Use (UI)
- Upload or drag an image
- Optionally select a noise profile
- Click Run Pipeline
What You Will See
Stage 1 OCR:
- Extracted text
- Character count
- Confidence
- Noise profile
- Denoiser usage
Stage 2 Compression:
- Compressed output
- Compression ratio
- Entropy
- Encoding efficiency
Final:
- Decompressed text
- Lossless match verification
- End-to-end latency
Architecture Overview
Stage 1 OCR:
- CNN: OCRNet (EMNIST-based)
- Denoiser: DnCNN
- Pipeline: image → denoise → segment → classify → text
Stage 2 Compression:
- Custom Adaptive Huffman Encoding (Vitter's Algorithm V)
- Fully lossless
Command-Line Demo (Optional)
This section is not required for judges.
Start services manually:
Terminal 1: cd pipeline/stage1_ocr python service.py --port 5001 --weights weights/ocr_model_best.pth --denoiser-weights weights/denoiser_best.pth
Terminal 2: cd pipeline/stage2_compression python service.py --port 5002
Then:
cd pipeline python pipeline_demo.py --images --noise none
Full Dataset Evaluation
cd pipeline python run_on_dataset.py --csv results.csv
Evaluates all images in SimulatedNoisyOffice and writes metrics.
Notes for Judges
- One command to run everything
- No training required
- Includes OCR + denoising + compression
- Custom Huffman implementation
- Lossless recovery verified
Log in or sign up for Devpost to join the conversation.