This repository contains a comprehensive pipeline for face enhancement, including face extraction, SRCNN-based super-resolution, and GAN-based deblurring. The project is structured to handle face images, enhance their resolution, and remove any blur, resulting in high-quality outputs.
The pipeline processes face images through the following steps:
- Face Extraction: Detects and crops faces from input images using a Haar Cascade classifier.
- SRCNN (Super-Resolution): Enhances the resolution of the cropped faces using a Super-Resolution Convolutional Neural Network (SRCNN).
- Deblurring: Removes any blur from the SRCNN-enhanced images using a GAN-based model.
The project requires the following dependencies:
- Python 3.8+
- TensorFlow
- OpenCV
- NumPy
- scikit-image
- Matplotlib
-
Clone the repository:
git clone https://github.com/who-else-but-arjun/Doraemon.git cd Doraemon
-
Ensure you have the required
.h5
weight files (generator.h5
for SRCNN and3051crop_weight_200.h5
for the deblurring model) in the project directory. -
Place your input images in a directory, e.g.,
input_faces/
.
The pipeline is outlined in the pipeline.ipynb
Jupyter notebook, which walks through the entire process:
- Face Extraction: Using
faceCrop.py
, it extracts faces from the input images. - Super-Resolution with SRCNN: Using
SRCNN.py
, it applies the SRCNN model trained ongenerator.h5
weights to enhance the image resolution. - Deblurring: Using
DeblurGANv2.py
, it removes any blur from the SRCNN output using a pre-trained GAN model, with layers defined inlayer_util.py
.
pipeline.ipynb
: Jupyter notebook containing the step-by-step process from face extraction to enhancement and deblurring.SRCNN.py
: Implements the SRCNN model for super-resolution, loading pre-trained weights fromgenerator.h5
.faceCrop.py
: Contains the Haar Cascade classifier logic for face detection and cropping.DeblurGANv2.py
: Implements the GAN model for deblurring images, loading weights fromdeblur_generator.h5
.layer_util.py
: Contains utility functions, including ResNet blocks necessary for the deblurring model.
-
Face Extraction:
python faceCrop.py --input_folder input_faces --output_folder cropped_faces
-
SRCNN Super-Resolution:
python srcnn.py --input_folder cropped_faces --output_folder srcnn_output --weights generator.h5
-
Deblurring:
python deblur_gan_v2.py --input_folder srcnn_output --output_folder deblurred_output --weights deblur_generator.h5
-
Run the entire pipeline:
Execute all steps sequentially in the
pipeline.ipynb
notebook.
The results of the pipeline will be saved in the specified output directories. You can compare the before and after images to evaluate the improvement in image quality.