Debluring Application
This application provides tools for deblurring images using deep learning. The system consists of:
- A DeblurGAN module for image deblurring using deep learning
- A FastAPI backend for processing images via API endpoints
- A Streamlit frontend for a user-friendly web interface
Features
- Upload and deblur images with a single click
- Modern web interface with side-by-side comparison of original and deblurred images
- Download deblurred results
- GPU-accelerated processing (with fallback to CPU)
- Command-line interface for batch processing
Requirements
- Python 3.7+
- PyTorch
- CUDA (optional, for GPU acceleration)
- Other dependencies listed in requirements.txt
Setup Instructions
- Clone this repository:
git clone <repo-url>
cd Debluring
- Install dependencies:
pip install -r requirements.txt
Note: This application requires the pretrainedmodels package for the deblurring model. If you encounter any issues, you can manually install the required packages:
pip install pretrainedmodels torchsummary albumentations opencv-python-headless
Running the Application
You can run the application in three different ways:
1. Standalone DeblurGAN Module
Process all images in the inputs/ directory and save results to outputs/:
python deblur_module.py
2. API Server
Start the FastAPI server:
python api.py
The API will be available at: http://localhost:8001
- POST
/deblur/- Upload an image for deblurring - GET
/status/- Check API status - GET
/diagnostics/- Get system diagnostics
3. Web Interface
First, ensure the API server is running, then start the Streamlit interface:
python app.py
The web UI will be available at: http://localhost:8501
4. All-in-One (Optional)
Use the run.py script to start both the API server and the Streamlit interface:
python run.py
Using the Application
Command-line mode:
- Place your blurry images in the
inputs/directory - Run
python deblur_module.py - Find the deblurred results in the
outputs/directory
- Place your blurry images in the
Web interface mode:
- Start both the API and the Streamlit app
- Upload an image through the web interface
- Click "Deblur Image" and wait for processing
- Download the deblurred image when ready
Troubleshooting
If you encounter any issues:
Check the API diagnostics endpoint: http://localhost:8001/diagnostics/
Review logs in the
logs/directory for detailed error information.Make sure your system has sufficient resources for running the deblurring model.
If you're experiencing CUDA errors, the application will automatically fall back to CPU processing.
For large images, the application will automatically resize them to a maximum dimension of 2000 pixels to avoid memory issues.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
This application is based on the DeblurGAN architecture for image deblurring with modifications to create a user-friendly interface and robust error handling.