manhkhanhUIT commited on
Commit
57a20fc
·
1 Parent(s): 989f4bb

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -257
README.md DELETED
@@ -1,257 +0,0 @@
1
- # Old Photo Restoration (Official PyTorch Implementation)
2
-
3
- <img src='imgs/0001.jpg'/>
4
-
5
- ### [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://hkustconnect-my.sharepoint.com/:f:/g/personal/bzhangai_connect_ust_hk/Em0KnYOeSSxFtp4g_dhWdf0BdeT3tY12jIYJ6qvSf300cA?e=nXkJH2) | [Colab Demo](https://colab.research.google.com/drive/1NEm6AsybIiC5TwTU_4DqDkQO0nFRB-uA?usp=sharing) | [Replicate Demo & Docker Image](https://replicate.ai/zhangmozhe/bringing-old-photos-back-to-life) :fire:
6
-
7
- **Bringing Old Photos Back to Life, CVPR2020 (Oral)**
8
-
9
- **Old Photo Restoration via Deep Latent Space Translation, PAMI Under Review**
10
-
11
- [Ziyu Wan](http://raywzy.com/)<sup>1</sup>,
12
- [Bo Zhang](https://www.microsoft.com/en-us/research/people/zhanbo/)<sup>2</sup>,
13
- [Dongdong Chen](http://www.dongdongchen.bid/)<sup>3</sup>,
14
- [Pan Zhang](https://panzhang0212.github.io/)<sup>4</sup>,
15
- [Dong Chen](https://www.microsoft.com/en-us/research/people/doch/)<sup>2</sup>,
16
- [Jing Liao](https://liaojing.github.io/html/)<sup>1</sup>,
17
- [Fang Wen](https://www.microsoft.com/en-us/research/people/fangwen/)<sup>2</sup> <br>
18
- <sup>1</sup>City University of Hong Kong, <sup>2</sup>Microsoft Research Asia, <sup>3</sup>Microsoft Cloud AI, <sup>4</sup>USTC
19
-
20
- <!-- ## Notes of this project
21
- The code originates from our research project and the aim is to demonstrate the research idea, so we have not optimized it from a product perspective. And we will spend time to address some common issues, such as out of memory issue, limited resolution, but will not involve too much in engineering problems, such as speedup of the inference, fastapi deployment and so on. **We welcome volunteers to contribute to this project to make it more usable for practical application.** -->
22
-
23
- ## :sparkles: News
24
- The framework now supports the restoration of high-resolution input.
25
-
26
- <img src='imgs/HR_result.png'>
27
-
28
- Training code is available and welcome to have a try and learn the training details.
29
-
30
- You can now play with our [Colab](https://colab.research.google.com/drive/1NEm6AsybIiC5TwTU_4DqDkQO0nFRB-uA?usp=sharing) and try it on your photos.
31
-
32
- ## Requirement
33
- The code is tested on Ubuntu with Nvidia GPUs and CUDA installed. Python>=3.6 is required to run the code.
34
-
35
- ## Installation
36
-
37
- Clone the Synchronized-BatchNorm-PyTorch repository for
38
-
39
- ```
40
- cd Face_Enhancement/models/networks/
41
- git clone https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
42
- cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm .
43
- cd ../../../
44
- ```
45
-
46
- ```
47
- cd Global/detection_models
48
- git clone https://github.com/vacancy/Synchronized-BatchNorm-PyTorch
49
- cp -rf Synchronized-BatchNorm-PyTorch/sync_batchnorm .
50
- cd ../../
51
- ```
52
-
53
- Download the landmark detection pretrained model
54
-
55
- ```
56
- cd Face_Detection/
57
- wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
58
- bzip2 -d shape_predictor_68_face_landmarks.dat.bz2
59
- cd ../
60
- ```
61
-
62
- 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.
63
-
64
- ```
65
- cd Face_Enhancement/
66
- wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/face_checkpoints.zip
67
- unzip face_checkpoints.zip
68
- cd ../
69
- cd Global/
70
- wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/global_checkpoints.zip
71
- unzip global_checkpoints.zip
72
- cd ../
73
- ```
74
-
75
- Install dependencies:
76
-
77
- ```bash
78
- pip install -r requirements.txt
79
- ```
80
-
81
- ## :rocket: How to use?
82
-
83
- **Note**: GPU can be set 0 or 0,1,2 or 0,2; use -1 for CPU
84
-
85
- ### 1) Full Pipeline
86
-
87
- You could easily restore the old photos with one simple command after installation and downloading the pretrained model.
88
-
89
- For images without scratches:
90
-
91
- ```
92
- python run.py --input_folder [test_image_folder_path] \
93
- --output_folder [output_path] \
94
- --GPU 0
95
- ```
96
-
97
- For scratched images:
98
-
99
- ```
100
- python run.py --input_folder [test_image_folder_path] \
101
- --output_folder [output_path] \
102
- --GPU 0 \
103
- --with_scratch
104
- ```
105
-
106
- **For high-resolution images with scratches**:
107
-
108
- ```
109
- python run.py --input_folder [test_image_folder_path] \
110
- --output_folder [output_path] \
111
- --GPU 0 \
112
- --with_scratch \
113
- --HR
114
- ```
115
-
116
- 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`.
117
-
118
- ### 2) Scratch Detection
119
-
120
- 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.
121
-
122
- ```
123
- cd Global/
124
- python detection.py --test_path [test_image_folder_path] \
125
- --output_dir [output_path] \
126
- --input_size [resize_256|full_size|scale_256]
127
- ```
128
-
129
- <img src='imgs/scratch_detection.png'>
130
-
131
- ### 3) Global Restoration
132
-
133
- A triplet domain translation network is proposed to solve both structured degradation and unstructured degradation of old photos.
134
-
135
- <p align="center">
136
- <img src='imgs/pipeline.PNG' width="50%" height="50%"/>
137
- </p>
138
-
139
- ```
140
- cd Global/
141
- python test.py --Scratch_and_Quality_restore \
142
- --test_input [test_image_folder_path] \
143
- --test_mask [corresponding mask] \
144
- --outputs_dir [output_path]
145
-
146
- python test.py --Quality_restore \
147
- --test_input [test_image_folder_path] \
148
- --outputs_dir [output_path]
149
- ```
150
-
151
- <img src='imgs/global.png'>
152
-
153
-
154
- ### 4) Face Enhancement
155
-
156
- We use a progressive generator to refine the face regions of old photos. More details could be found in our journal submission and `./Face_Enhancement` folder.
157
-
158
- <p align="center">
159
- <img src='imgs/face_pipeline.jpg' width="60%" height="60%"/>
160
- </p>
161
-
162
-
163
- <img src='imgs/face.png'>
164
-
165
- > *NOTE*:
166
- > This repo is mainly for research purpose and we have not yet optimized the running performance.
167
- >
168
- > Since the model is pretrained with 256*256 images, the model may not work ideally for arbitrary resolution.
169
-
170
- ### 5) GUI
171
-
172
- A user-friendly GUI which takes input of image by user and shows result in respective window.
173
-
174
- #### How it works:
175
-
176
- 1. Run GUI.py file.
177
- 2. Click browse and select your image from test_images/old_w_scratch folder to remove scratches.
178
- 3. Click Modify Photo button.
179
- 4. Wait for a while and see results on GUI window.
180
- 5. Exit window by clicking Exit Window and get your result image in output folder.
181
-
182
- <img src='imgs/gui.PNG'>
183
-
184
- ## How to train?
185
-
186
- ### 1) Create Training File
187
-
188
- Put the folders of VOC dataset, collected old photos (e.g., Real_L_old and Real_RGB_old) into one shared folder. Then
189
- ```
190
- cd Global/data/
191
- python Create_Bigfile.py
192
- ```
193
- Note: Remember to modify the code based on your own environment.
194
-
195
- ### 2) Train the VAEs of domain A and domain B respectively
196
-
197
- ```
198
- cd ..
199
- python train_domain_A.py --use_v2_degradation --continue_train --training_dataset domain_A --name domainA_SR_old_photos --label_nc 0 --loadSize 256 --fineSize 256 --dataroot [your_data_folder] --no_instance --resize_or_crop crop_only --batchSize 100 --no_html --gpu_ids 0,1,2,3 --self_gen --nThreads 4 --n_downsample_global 3 --k_size 4 --use_v2 --mc 64 --start_r 1 --kl 1 --no_cgan --outputs_dir [your_output_folder] --checkpoints_dir [your_ckpt_folder]
200
-
201
- python train_domain_B.py --continue_train --training_dataset domain_B --name domainB_old_photos --label_nc 0 --loadSize 256 --fineSize 256 --dataroot [your_data_folder] --no_instance --resize_or_crop crop_only --batchSize 120 --no_html --gpu_ids 0,1,2,3 --self_gen --nThreads 4 --n_downsample_global 3 --k_size 4 --use_v2 --mc 64 --start_r 1 --kl 1 --no_cgan --outputs_dir [your_output_folder] --checkpoints_dir [your_ckpt_folder]
202
- ```
203
- Note: For the --name option, please ensure your experiment name contains "domainA" or "domainB", which will be used to select different dataset.
204
-
205
- ### 3) Train the mapping network between domains
206
-
207
- Train the mapping without scratches:
208
- ```
209
- python train_mapping.py --use_v2_degradation --training_dataset mapping --use_vae_which_epoch 200 --continue_train --name mapping_quality --label_nc 0 --loadSize 256 --fineSize 256 --dataroot [your_data_folder] --no_instance --resize_or_crop crop_only --batchSize 80 --no_html --gpu_ids 0,1,2,3 --nThreads 8 --load_pretrainA [ckpt_of_domainA_SR_old_photos] --load_pretrainB [ckpt_of_domainB_old_photos] --l2_feat 60 --n_downsample_global 3 --mc 64 --k_size 4 --start_r 1 --mapping_n_block 6 --map_mc 512 --use_l1_feat --niter 150 --niter_decay 100 --outputs_dir [your_output_folder] --checkpoints_dir [your_ckpt_folder]
210
- ```
211
-
212
-
213
- Traing the mapping with scraches:
214
- ```
215
- python train_mapping.py --no_TTUR --NL_res --random_hole --use_SN --correlation_renormalize --training_dataset mapping --NL_use_mask --NL_fusion_method combine --non_local Setting_42 --use_v2_degradation --use_vae_which_epoch 200 --continue_train --name mapping_scratch --label_nc 0 --loadSize 256 --fineSize 256 --dataroot [your_data_folder] --no_instance --resize_or_crop crop_only --batchSize 36 --no_html --gpu_ids 0,1,2,3 --nThreads 8 --load_pretrainA [ckpt_of_domainA_SR_old_photos] --load_pretrainB [ckpt_of_domainB_old_photos] --l2_feat 60 --n_downsample_global 3 --mc 64 --k_size 4 --start_r 1 --mapping_n_block 6 --map_mc 512 --use_l1_feat --niter 150 --niter_decay 100 --outputs_dir [your_output_folder] --checkpoints_dir [your_ckpt_folder] --irregular_mask [absolute_path_of_mask_file]
216
- ```
217
-
218
- Traing the mapping with scraches (Multi-Scale Patch Attention for HR input):
219
- ```
220
- python train_mapping.py --no_TTUR --NL_res --random_hole --use_SN --correlation_renormalize --training_dataset mapping --NL_use_mask --NL_fusion_method combine --non_local Setting_42 --use_v2_degradation --use_vae_which_epoch 200 --continue_train --name mapping_Patch_Attention --label_nc 0 --loadSize 256 --fineSize 256 --dataroot [your_data_folder] --no_instance --resize_or_crop crop_only --batchSize 36 --no_html --gpu_ids 0,1,2,3 --nThreads 8 --load_pretrainA [ckpt_of_domainA_SR_old_photos] --load_pretrainB [ckpt_of_domainB_old_photos] --l2_feat 60 --n_downsample_global 3 --mc 64 --k_size 4 --start_r 1 --mapping_n_block 6 --map_mc 512 --use_l1_feat --niter 150 --niter_decay 100 --outputs_dir [your_output_folder] --checkpoints_dir [your_ckpt_folder] --irregular_mask [absolute_path_of_mask_file] --mapping_exp 1
221
- ```
222
-
223
-
224
- ## Citation
225
-
226
- If you find our work useful for your research, please consider citing the following papers :)
227
-
228
- ```bibtex
229
- @inproceedings{wan2020bringing,
230
- title={Bringing Old Photos Back to Life},
231
- author={Wan, Ziyu and Zhang, Bo and Chen, Dongdong and Zhang, Pan and Chen, Dong and Liao, Jing and Wen, Fang},
232
- booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
233
- pages={2747--2757},
234
- year={2020}
235
- }
236
- ```
237
-
238
- ```bibtex
239
- @article{wan2020old,
240
- title={Old Photo Restoration via Deep Latent Space Translation},
241
- author={Wan, Ziyu and Zhang, Bo and Chen, Dongdong and Zhang, Pan and Chen, Dong and Liao, Jing and Wen, Fang},
242
- journal={arXiv preprint arXiv:2009.07047},
243
- year={2020}
244
- }
245
- ```
246
-
247
- If you are also interested in the legacy photo/video colorization, please refer to [this work](https://github.com/zhangmozhe/video-colorization).
248
-
249
- ## Maintenance
250
-
251
- This project is currently maintained by Ziyu Wan and is for academic research use only. If you have any questions, feel free to contact [email protected].
252
-
253
- ## License
254
-
255
- The codes and the pretrained model in this repository are under the MIT license as specified by the LICENSE file. We use our labeled dataset to train the scratch detection model.
256
-
257
- This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.