File size: 3,159 Bytes
61d360d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Debluring Application

This application provides tools for deblurring images using deep learning. The system consists of:

1. A **DeblurGAN module** for image deblurring using deep learning
2. A **FastAPI backend** for processing images via API endpoints
3. 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

1. Clone this repository:

```
git clone <repo-url>
cd Debluring
```

2. 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

1. **Command-line mode**:

   - Place your blurry images in the `inputs/` directory
   - Run `python deblur_module.py`
   - Find the deblurred results in the `outputs/` directory

2. **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:

1. Check the API diagnostics endpoint: http://localhost:8001/diagnostics/

2. Review logs in the `logs/` directory for detailed error information.

3. Make sure your system has sufficient resources for running the deblurring model.

4. If you're experiencing CUDA errors, the application will automatically fall back to CPU processing.

5. 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.