⭐ If SSDiff is helpful to your paper or project, please consider star this repo or cite our paper. Thanks! 🤗
- 2025.02.11: Datas are relased.
- 2025.12.07: Codes are relased.
- 2025.12.03: Checkpoints and scripts are relased.
- 2025.12.02: Config files are relased.
- 2025.10.11: This repo is created.
- Relase restoration results.
- Relase our constructed old-photo face dataset, VintageFace.
- Relase checkpoint and script for old photo face restoration.
- Relase codes and config files.
- Release paper on arxiv.
- Pytorch >= 1.7.1
- CUDA >= 10.1
- Other required packages in
requirements.txt
# git clone this repository
git clone https://github.com/PRIS-CV/SSDiff
cd SSDiff
# create new anaconda env
conda create -n SSDiff python=3.8 -y
conda activate SSDiff
# install python dependencies
conda install mpi4py
pip3 install -r requirements.txt
pip install -e .
Download the pretrained face generation diffusion model iddpm_ffhq512_ema500000.pth from [Google Drive] to models folder, the pretrained face parsing model resnet34.pt from [Google Drive] to models/face_parsing folder, the pretrained style transfer model photo_image.pt from [Google Drive] to CAP_VSTNet/checkpoints folder.
Download the facelib and dlib pretrained models from [Releases | OneDrive] to the weights/facelib folder and weights folder, separately. You can manually download the pretrained models OR download by running the following command:
python scripts/download_pretrained_models.py facelib
python scripts/download_pretrained_models.py dlib (only for dlib face detector)
Download the pretrained restore model codeformer.pth and pretrained VQGAN model vqgan_code1024.pth from [Releases | OneDrive] to the models/restorer folder and models/vqgan folder, separately. You can manually download the pretrained models OR download by running the following command:
python scripts/download_pretrained_models.py CodeFormer
Download the real-world old face photo test set that collected from the Internet called VintageFace from [Google Drive], including old face photos with their corresponding processed masks.
You can put the testing images in the inputs/TestWhole folder. If you would like to test on cropped and aligned faces, you can put them in the inputs/cropped_faces folder. You can get the cropped and aligned faces by running the following command:
# you may need to install dlib via: conda install -c conda-forge dlib
python extract_faces.py -i [input folder] -o [output folder]
- If scratches exist, a folder for mask(s)
mask_dirmust be specified with the name of each mask image corresponding to that of each input image. Each input mask shoud be a binary map with white pixels representing masked regions. To obtain a scratch map automatically, we recommend using the scratch detection model. One may also further adjust the scratch map with an image editing app (e.g., Photoshop).
You can download visual results from Google Drive.
🧑🏻 Old-Photo Face Restoration (cropped and aligned face)
# For generating reference pseudo-labelled faces (512x512)
python inference_fake_label.py --task old_photo_restoration_pseudo --in_dir [input_image_path] --mask_dir [mask_path] --out_dir [output_image_path] --guidance_scale 0.001 --seed 4321
# For breakage, fading, and blur faces (512x512)
# --self_dir refers to the path of the pseudo-labelled faces generated in the previous stage.
python inference_final.py --task old_photo_restoration --in_dir [input_image_path] --mask_dir [mask_path] --out_dir [output_image_path] --guidance_scale 0.0035 --self_dir [pseudo_labelled_faces_path] --seed 4321
🧑🏻 Face Restoration (cropped and aligned face)
# For only blur faces (512x512), You may choose not to use pseudo-labelled faces.
python inference_final.py --task restoration --in_dir [input_image_path] --out_dir [output_image_path] --guidance_scale 0.05
If our work is useful for your research, please consider citing:
@inproceedings{li2025self,
title={Self-Supervised Selective-Guided Diffusion Model for Old-Photo Face Restoration},
author={Li, Wenjie and Wang, Xiangyi and Guo, Heng and Gao, Guangwei and Ma, Zhanyu},
booktitle={NeurIPs},
year={2025}
}
If you have any questions, please feel free to reach me out at lewj2408@gmail.com.