
Image Enhancement Web Service
AI-powered image enhancement with super-resolution (16x/4x upscaling), low-light enhancement, color correction, and face restoration using Real-ESRGAN, GFPGAN, and custom algorithms.
Timeline
January 2026 - February 2026
Role
Creator
Team
Solo
Status
CompletedTechnology Stack
Key Challenges
- GPU memory optimization
- Multi-algorithm coordination
- Image quality assessment
- Batch processing
Key Learnings
- Advanced image processing with OpenCV
- Deep learning model deployment
- FastAPI async processing
- Docker containerization
Overview
A professional-grade AI image enhancement service that transforms mobile phone photos into high-quality, professional images. Built with state-of-the-art deep learning models, the service offers a modular pipeline combining super-resolution, face restoration, low-light enhancement, and color correction.
Optimized for deployment on HuggingFace Spaces with free GPU access, making high-quality image enhancement accessible to everyone.
Key Features
Super-Resolution (Upscaling)
- Real-ESRGAN: 4x upscaling with preserved details
- super-image: Alternative upscaling with tile processing for large images
- Supports both 16x (for tiny images) and 4x (standard) upscaling factors
Low-Light Enhancement
- CLAHE: Contrast Limited Adaptive Histogram Equalization
- CSEC: Color and Spatial Enhancement for low-light conditions
- Brightens dark images while reducing noise
Color Correction
- Deep White Balance: Learning-based white balancing
- Exposure Correction: Automatic brightness and contrast adjustment
- Fixes color casts and underexposed photos
Face Enhancement
- GFPGAN: Generative Facial Priors GAN for face restoration
- Reconstructs facial details in low-quality or blurred faces
- Maintains natural appearance without over-processing
Smart Analysis
Automatic detection of required enhancements:
- Brightness check → applies low-light enhancement if too dark
- Face detection → applies GFPGAN if faces found
- Resolution check → chooses appropriate upscaling factor
Algorithm Performance (GTX 1650 Ti)
Tested on 1728×2304 test image (≈4MP):
| Algorithm | Time | GPU | Notes | |-----------|------|-----|--------| | Real-ESRGAN (4x) | 99.8s | ✅ | High quality, 4× upscaling | | GFPGAN (face) | 3.0s | ✅ | Face restoration | | CLAHE | 162ms | ❌ | CPU-based | | White Balance | 64ms | ❌ | CPU-based | | Exposure Correction | 58ms | ❌ | CPU-based |
Total pipeline time: ~105 seconds for full enhancement (upscale + face + color + exposure)
API Endpoints
POST /api/v1/enhance
Request: { image: base64, algorithms: ['auto'], parameters: { upscale_factor: 'auto', quality: 'high' } }
Response: { enhanced_image: base64, metadata: {...} }
POST /api/v1/enhance/batch
Request: Multiple images
Response: Array of enhanced results
GET /api/v1/algorithms
Response: List of available algorithms with descriptions
GET /api/v1/status
Response: System health, GPU status, model load timesTech Stack
- Backend: Python, FastAPI, Uvicorn
- AI Models: PyTorch, Real-ESRGAN, GFPGAN, OpenCV
- Hardware: NVIDIA GPU (CUDA 11.8+)
- Deployment: Docker, HuggingFace Spaces, Railway, Render
- Storage: Google Drive API (batch processing), Local FS
Validation Results
✅ 15/15 images successfully enhanced (100% success rate)
- Proper 4x upscaling verified: 1728×2304 → 6912×9216
- Face enhancement maintained natural appearance
- Low-light images brightened without noise amplification
- Color corrections eliminated color casts
User feedback: "I find the result good this time" — after iterative improvements.
Architecture
User Upload → Image Analyzer → Enhancement Pipeline → Output
↓ ↓ ↓ ↓
Base64/File Brightness/Face/ Real-ESRGAN → Enhanced
Resolution GFPGAN Image
CLAHE/WB/Exposure
Pipeline Flow
- Analyze image properties (brightness, faces, resolution)
- Decide which algorithms to apply (auto mode)
- Execute enhancement pipeline sequentially
- Return enhanced image + metadata
Challenges & Solutions
Challenge 1: GPU Memory (4GB VRAM limit)
Large images caused CUDA out-of-memory errors. Solution: Implemented tiling for large images, reduced batch size, processed sequentially instead of parallel.
Challenge 2: Model Compatibility
Different models expected different input formats and preprocessing.
Solution: Created unified BaseEnhancer interface; each algorithm handles its own preprocessing, returns standard format.
Challenge 3: JSON Serialization
NumPy arrays cannot be directly JSON-serialized. Solution: Convert to PIL Image → base64 string for API responses; also optionally save to disk.
Challenge 4: Performance
Combined pipeline could take several minutes. Solution: Made pipeline asynchronous with progress tracking; user gets task ID and polls for completion.
Deployment Options
HuggingFace Spaces (RECOMMENDED)
- Free GPU (A10G/T4), 16GB RAM, 50GB storage
- Automatic builds from GitHub
- 1-click deployment
Railway
- GPU-enabled instances
- Easy config via environment variables
Render
- Web Service with GPU
- Persistent storage for models
Local Docker
docker build -t img-enhance .
docker run -p 8000:8000 img-enhanceFuture Enhancements
- Video enhancement (frame-by-frame)
- Batch processing from cloud storage (S3, GCS)
- User accounts and enhancement history
- Subscription-based credit system
- REST + WebSocket for real-time progress
- Mobile SDK (iOS/Android)
Try It Out
Since deployment requires GPU, the easiest way is to deploy to HuggingFace Spaces — follow the setup guide in the repo's README.
Once deployed, send a POST request with a base64-encoded image and receive the enhanced version in seconds.
