← BACK TO PORTFOLIO

AI ADAPTIVE IMAGE COMPRESSION

AI-based compression system intelligently preserving text and fine details using deep learning and OCR.

RoleML Engineer
Timeline2024
Tech StackPython, TensorFlow, OpenCV, Tesseract OCR

OVERVIEW

Conventional image compression applies a uniform reduction across the entire canvas, frequently degrading essential information such as text and fine details. This project introduces a context-aware, adaptive compression pipeline powered by deep learning and Optical Character Recognition (OCR). The system autonomously identifies critical regions, guaranteeing the preservation of readability and structural clarity while aggressively minimizing overall file size.

AI Image Compression Result 1
AI Image Compression Result 2
AI Image Compression Result 3
AI Image Compression Result 4

KEY FEATURES

  • Tile-Based Processing: Dynamically segments images into discrete, non-overlapping tiles for granular analysis and compression.
  • Deep Learning Classification: Utilizes a custom-trained neural network architecture to identify visually critical and human-centric regions.
  • OCR-Aware Preservation: Integrates Tesseract OCR to strictly safeguard text and structural elements from compression degradation.
  • Adaptive Compression Strategy: Dynamically allocates high quality to critical regions while aggressively compressing less important background noise.
  • Interactive Visualization: Provides a responsive Streamlit interface featuring a visual heatmap of detected regions and compression metrics.
  • Significant Size Reduction: Achieves 60–80% reductions in file size while maintaining a near-lossless perceived visual quality.

HOW IT WORKS

1. Data Segmentation & Preprocessing
The input image is divided into small, non-overlapping grid tiles. Each tile undergoes preprocessing to standardize spatial dimensions and normalize color channels prior to evaluation.
2. Neural Network Evaluation
A custom convolutional neural network evaluates each tile, identifying high-priority elements—such as faces, salient objects, and intricate textures—that are vulnerable to standard compression artifacts.
3. Semantic Text Preservation
The pipeline concurrently analyzes tiles via Tesseract OCR. Any detected text characters or structural typography automatically flag the tile as 'Critical,' ensuring zero loss of legibility.
4. Adaptive Reconstruction
The system applies dynamic compression ratios dictated by tile classification. 'Critical' tiles retain near-lossless fidelity, whereas background tiles are aggressively compressed. The grid is subsequently reassembled into a highly optimized file.

PROJECT STRUCTURE

app.py           # Streamlit web application
train.py         # Model training script
classify.py      # Dataset preprocessing & OCR labeling

# Excluded from repository:
# /dataset, /processed, /outputs, /models

INSTALLATION & DEPENDENCIES

1. Clone and install dependencies:

git clone https://github.com/USERNAME/ai-adaptive-image-compression.git
cd ai-adaptive-image-compression
pip install -r requirements.txt

2. External Dependencies (Tesseract OCR):

This project requires Tesseract OCR to be installed separately and added to your system PATH.

HOW TO RUN & TRAIN

Running the Web Application:

streamlit run app.py

Training the Model:

python train.py

Dataset and trained models are excluded due to size.