Zoro828/imageRestoration
๐ผ๏ธ Image Restoration Studio
<div align="center">
    ![Status]()
Professional-grade image restoration with multi-algorithm inpainting
โข Report Bug โข Request Feature
<img src="https://github.com/FarazKhanAI/ImageRestoration/blob/main/demo.gif?raw=true" width="600" alt="Image Restoration Demo">
</div>
๐ฏ What It Does
Restore damaged photos with AI-powered precision. Remove scratches, blemishes, and unwanted objects while preserving original details and colors.
โจ Key Features
- โ Multi-Algorithm Inpainting - Combines Telea, Navier-Stokes, and hybrid methods
- โ Smart Mask Processing - Feathering and edge-aware mask creation
- โ Color Preservation - Maintains original color consistency
- โ Fast Processing - 2-10 seconds for most images
- โ Batch Processing - Automatically saves masks and results
๐ Get Started in 2 Minutes
Prerequisites
- Python 3.10 or higher
- Git (optional)
Installation
# 1. Clone the repository
git clone https://github.com/FarazKhanAI/ImageRestoration.git
cd ImageRestoration
# 2. Create virtual environment (optional but recommended)
python -m venv venv
# 3. Activate environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate
# 4. Install dependencies
pip install -r requirements.txt
# 5. Run the application
python app.pyOpen your browser and visit: http://localhost:5000
๐ How to Use
Step 1: Upload Image
- Drag & drop your image or click to browse
- Supports JPG, PNG, BMP, TIFF (up to 16MB)
Step 2: Mark Damage Areas
- Use the brush tool to mark scratches, stains, or objects
- Adjust brush size with the slider
- Use Undo/Clear if needed
Step 3: Adjust Parameters
- Inpainting Method:
Fast (Telea)- Quick restorationQuality (Navier-Stokes)- Better for texturesHybrid- Best overall (recommended)- Brush Size: 5-100px
- Inpainting Radius: 1-20px
Step 4: Process & Download
- Click "Process & Restore Image"
- View before/after comparison
- Download restored image in high quality
๐๏ธ Technical Architecture
Backend Stack
Processing Pipeline
1. Image Upload โ Validation โ Resize
2. Mask Creation โ Feathering โ Dilation
3. Inpainting Selection โ Algorithm execution
4. Color Correction โ Post-processing
5. Result Generation โ Metrics calculation๐ Project Structure
image-restoration-app/
โโโ app.py # Main Flask application
โโโ config.py # Configuration settings
โโโ requirements.txt # Python dependencies
โ
โโโ backend/ # Core processing logic
โ โโโ image_processor.py # Main processing pipeline
โ โโโ scratch_removal.py # Advanced inpainting algorithms
โ โโโ utils.py # Helper functions (mask creation, I/O)
โ โโโ enhancement.py # Color adjustments (optional)
โ โโโ validators.py # Input validation
โ
โโโ templates/ # Frontend HTML
โ โโโ base.html # Base layout
โ โโโ index.html # Main interface
โ
โโโ static/ # Web assets
โ โโโ css/style.css # Styling
โ โโโ js/main.js # Interactive features
โ
โโโ instance/ # User data (not in git)
โโโ uploads/raw/ # Original uploaded images
โโโ uploads/masks/ # Generated mask images
โโโ processed/ # Restored output images๐ง Advanced Inpainting Algorithms
Multi-Algorithm Strategy
The system intelligently selects the best algorithm based on damage size:
Key Technical Improvements
- Edge Preservation - Uses Canny edge detection to protect boundaries
- Color Matching - Adjusts inpainted colors to match surroundings
- Multi-Scale Processing - Handles different damage sizes optimally
- Soft Mask Blending - Feathering prevents visible seams
โก Performance & Optimization
Processing Times
Memory Usage
- Minimal footprint: ~100MB for typical images
- Auto-resizing: Large images automatically scaled to 2000px max dimension
- Efficient cleanup: Temporary files removed after processing
๐ข Deployment Options
Option 1: Local Development
python app.py
# Runs on http://localhost:5000 with debug modeOption 2: Production with Gunicorn
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:appOption 3: Free Cloud Deployment
Render.com (Recommended)
- Connect your GitHub repository
- Set build command:
pip install -r requirements.txt - Set start command:
python app.py - Get free HTTPS and auto-deploy
PythonAnywhere
- Upload files via web interface
- Configure WSGI file
- Free tier available (limited)
๐ง Configuration
Environment Variables
Create .env file for production:
SECRET_KEY=your-secret-key-here
MAX_CONTENT_LENGTH=16777216 # 16MB
DEBUG=FalseDirectory Setup
The application automatically creates:
instance/ # Created automatically
โโโ uploads/raw/ # Original images
โโโ uploads/masks/ # Mask images (saved here!)
โโโ processed/ # Final results๐ Troubleshooting
Common Issues & Solutions
Debug Mode
Enable debug logging by setting DEBUG = True in app.py:
# In app.py
DEBUG = True๐ค Contributing
We welcome contributions! Here's how to help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -m 'Add some improvement') - Push to the branch (
git push origin feature/improvement) - Open a Pull Request
Development Setup
# Clone and setup
git clone https://github.com/FarazKhanAI/ImageRestoration.git
cd ImageRestoration
pip install -r requirements.txt
# Run tests
python -m pytest tests/
# Format code
black .๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ง Support & Contact
- GitHub Issues: Report bugs or request features
- Email: [Your email or project email]
- Project Link: https://github.com/FarazKhanAI/ImageRestoration
๐ Acknowledgments
Special thanks to:
- OpenCV Team - For the incredible computer vision library
- Flask Community - For the lightweight web framework
- All Contributors - Who help improve this project
<div align="center">
Ready to restore your images?
Made with โค๏ธ using Flask & OpenCV
</div>
๐ Next Steps
Planned Improvements
- [ ] Batch Processing - Restore multiple images at once
- [ ] AI Enhancement - Add deep learning models for better results
- [ ] Mobile App - iOS/Android companion apps
- [ ] Cloud Storage - Google Drive/Dropbox integration
Frontend Updates (Coming Soon)
- Dark mode toggle
- More brush styles and shapes
- Real-time preview while drawing
- Advanced comparison slider
Tip: For best results, use high-quality source images and mark damage areas precisely with appropriate brush size.
