# Bringing-Old-Photos-Back-to-Life
**Repository Path**: chaoqun_python/Bringing-Old-Photos-Back-to-Life
## Basic Information
- **Project Name**: Bringing-Old-Photos-Back-to-Life
- **Description**: Bringing Old Photo Back to Life (CVPR 2020 oral)
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-12-26
- **Last Updated**: 2020-12-26
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Old Photo Restoration (Official PyTorch Implementation)
### [Project Page](http://raywzy.com/Old_Photo/) | [Paper (CVPR version)](https://arxiv.org/abs/2004.09484) | [Paper (Journal version)](https://arxiv.org/pdf/2009.07047v1.pdf) | [Pretrained Model](https://portland-my.sharepoint.com/:f:/g/personal/ziyuwan2-c_ad_cityu_edu_hk/Eh1gtjfLiWtLiBDGZhaTvokBvDUdvA5j49f_NpL_Pp9FPA?e=7EddTf) | [Colab Demo](https://colab.research.google.com/drive/1NEm6AsybIiC5TwTU_4DqDkQO0nFRB-uA?usp=sharing) :fire:
**Bringing Old Photos Back to Life, CVPR2020 (Oral)**
**Old Photo Restoration via Deep Latent Space Translation, PAMI Under Review**
[Ziyu Wan](http://raywzy.com/)1,
[Bo Zhang](https://www.microsoft.com/en-us/research/people/zhanbo/)2,
[Dongdong Chen](http://www.dongdongchen.bid/)3,
[Pan Zhang](https://panzhang0212.github.io/)4,
[Dong Chen](https://www.microsoft.com/en-us/research/people/doch/)2,
[Jing Liao](https://liaojing.github.io/html/)1,
[Fang Wen](https://www.microsoft.com/en-us/research/people/fangwen/)2
1City University of Hong Kong, 2Microsoft Research Asia, 3Microsoft Cloud AI, 4USTC
## New
You can now play with our [Colab](https://colab.research.google.com/drive/1NEm6AsybIiC5TwTU_4DqDkQO0nFRB-uA?usp=sharing) and try it on your photos.
## Requirement
The code is tested on Ubuntu with Nvidia GPUs and CUDA installed. Python>=3.6 is required to run the code.
## Installation
Clone the Synchronized-BatchNorm-PyTorch repository for
```
cd Face_Enhancement/models/networks/
git clone https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm .
cd ../../../
```
```
cd Global/detection_models
git clone https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm .
cd ../../
```
Download the landmark detection pretrained model
```
cd Face_Detection/
wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
cd ../
```
Download the pretrained model from Azure Blob Storage, put the file `Face_Enhancement/checkpoints.zip` under `./Face_Enhancement`, and put the file `Global/checkpoints.zip` under `./Global`. Then unzip them respectively.
```
cd Face_Enhancement/
wget https://facevc.blob.core.windows.net/zhanbo/old_photo/pretrain/Face_Enhancement/checkpoints.zip
unzip checkpoints.zip
cd ../
cd Global/
wget https://facevc.blob.core.windows.net/zhanbo/old_photo/pretrain/Global/checkpoints.zip
unzip checkpoints.zip
cd ../
```
Install dependencies:
```bash
pip install -r requirements.txt
```
## How to use?
**Note**:GPU can be set 0 or 0,1,2 or 0,2; use -1 for CPU
### 1) Full Pipeline
You could easily restore the old photos with one simple command after installation and downloading the pretrained model.
For images without scratches:
```
python run.py --input_folder [test_image_folder_path] \
--output_folder [output_path] \
--GPU 0
```
For scratched images:
```
python run.py --input_folder [test_image_folder_path] \
--output_folder [output_path] \
--GPU 0 \
--with_scratch
```
Note: Please try to use the absolute path. The final results will be saved in `./output_path/final_output/`. You could also check the produced results of different steps in `output_path`.
### 2) Scratch Detection
Currently we don't plan to release the scratched old photos dataset with labels directly. If you want to get the paired data, you could use our pretrained model to test the collected images to obtain the labels.
```
cd Global/
python detection.py --test_path [test_image_folder_path] \
--output_dir [output_path] \
--input_size [resize_256|full_size|scale_256]
```
### 3) Global Restoration
A triplet domain translation network is proposed to solve both structured degradation and unstructured degradation of old photos.