[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-70730":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":34,"readmeContent":35,"aiSummary":36,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":37,"discoverSource":38},70730,"Bringing-Old-Photos-Back-to-Life","microsoft\u002FBringing-Old-Photos-Back-to-Life","microsoft","Bringing Old Photo Back to Life (CVPR 2020 oral)","https:\u002F\u002Farxiv.org\u002Fabs\u002F2004.09484",null,"Python",15687,2090,288,98,0,2,3,6,75.26,"MIT License",false,"master",true,[26,27,28,29,30,31,32,33],"gans","generative-adversarial-network","image-manipulation","image-restoration","old-photo-restoration","photo-restoration","photos","pytorch","2026-06-12 04:00:56","# Old Photo Restoration (Official PyTorch Implementation)\n\n\u003Cimg src='imgs\u002F0001.jpg'\u002F>\n\n### [Project Page](http:\u002F\u002Fraywzy.com\u002FOld_Photo\u002F) | [Paper (CVPR version)](https:\u002F\u002Farxiv.org\u002Fabs\u002F2004.09484) | [Paper (Journal version)](https:\u002F\u002Farxiv.org\u002Fpdf\u002F2009.07047v1.pdf) | [Pretrained Model](https:\u002F\u002Fhkustconnect-my.sharepoint.com\u002F:f:\u002Fg\u002Fpersonal\u002Fbzhangai_connect_ust_hk\u002FEm0KnYOeSSxFtp4g_dhWdf0BdeT3tY12jIYJ6qvSf300cA?e=nXkJH2) | [Colab Demo](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1NEm6AsybIiC5TwTU_4DqDkQO0nFRB-uA?usp=sharing)  | [Replicate Demo & Docker Image](https:\u002F\u002Freplicate.ai\u002Fzhangmozhe\u002Fbringing-old-photos-back-to-life) :fire:\n\n**Bringing Old Photos Back to Life, CVPR2020 (Oral)**\n\n**Old Photo Restoration via Deep Latent Space Translation, TPAMI 2022**\n\n[Ziyu Wan](http:\u002F\u002Fraywzy.com\u002F)\u003Csup>1\u003C\u002Fsup>,\n[Bo Zhang](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Fresearch\u002Fpeople\u002Fzhanbo\u002F)\u003Csup>2\u003C\u002Fsup>,\n[Dongdong Chen](http:\u002F\u002Fwww.dongdongchen.bid\u002F)\u003Csup>3\u003C\u002Fsup>,\n[Pan Zhang](https:\u002F\u002Fpanzhang0212.github.io\u002F)\u003Csup>4\u003C\u002Fsup>,\n[Dong Chen](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Fresearch\u002Fpeople\u002Fdoch\u002F)\u003Csup>2\u003C\u002Fsup>,\n[Jing Liao](https:\u002F\u002Fliaojing.github.io\u002Fhtml\u002F)\u003Csup>1\u003C\u002Fsup>,\n[Fang Wen](https:\u002F\u002Fwww.microsoft.com\u002Fen-us\u002Fresearch\u002Fpeople\u002Ffangwen\u002F)\u003Csup>2\u003C\u002Fsup> \u003Cbr>\n\u003Csup>1\u003C\u002Fsup>City University of Hong Kong, \u003Csup>2\u003C\u002Fsup>Microsoft Research Asia, \u003Csup>3\u003C\u002Fsup>Microsoft Cloud AI, \u003Csup>4\u003C\u002Fsup>USTC\n\n\u003C!-- ## Notes of this project\nThe 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.** -->\n\n## :sparkles: News\n**2022.3.31**: Our new work regarding old film restoration will be published in CVPR 2022. For more details, please refer to the [project website](http:\u002F\u002Fraywzy.com\u002FOld_Film\u002F) and [github repo](https:\u002F\u002Fgithub.com\u002Fraywzy\u002FBringing-Old-Films-Back-to-Life).\n\nThe framework now supports the restoration of high-resolution input.\n\n\u003Cimg src='imgs\u002FHR_result.png'>\n\nTraining code is available and welcome to have a try and learn the training details. \n\nYou can now play with our [Colab](https:\u002F\u002Fcolab.research.google.com\u002Fdrive\u002F1NEm6AsybIiC5TwTU_4DqDkQO0nFRB-uA?usp=sharing) and try it on your photos. \n\n## Requirement\nThe code is tested on Ubuntu with Nvidia GPUs and CUDA installed. Python>=3.6 is required to run the code.\n\n## Installation\n\nClone the Synchronized-BatchNorm-PyTorch repository for\n\n```\ncd Face_Enhancement\u002Fmodels\u002Fnetworks\u002F\ngit clone https:\u002F\u002Fgithub.com\u002Fvacancy\u002FSynchronized-BatchNorm-PyTorch\ncp -rf Synchronized-BatchNorm-PyTorch\u002Fsync_batchnorm .\ncd ..\u002F..\u002F..\u002F\n```\n\n```\ncd Global\u002Fdetection_models\ngit clone https:\u002F\u002Fgithub.com\u002Fvacancy\u002FSynchronized-BatchNorm-PyTorch\ncp -rf Synchronized-BatchNorm-PyTorch\u002Fsync_batchnorm .\ncd ..\u002F..\u002F\n```\n\nDownload the landmark detection pretrained model\n\n```\ncd Face_Detection\u002F\nwget http:\u002F\u002Fdlib.net\u002Ffiles\u002Fshape_predictor_68_face_landmarks.dat.bz2\nbzip2 -d shape_predictor_68_face_landmarks.dat.bz2\ncd ..\u002F\n```\n\nDownload the pretrained model, put the file `Face_Enhancement\u002Fcheckpoints.zip` under `.\u002FFace_Enhancement`, and put the file `Global\u002Fcheckpoints.zip` under `.\u002FGlobal`. Then unzip them respectively.\n\n```\ncd Face_Enhancement\u002F\nwget https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBringing-Old-Photos-Back-to-Life\u002Freleases\u002Fdownload\u002Fv1.0\u002Fface_checkpoints.zip\nunzip face_checkpoints.zip\ncd ..\u002F\ncd Global\u002F\nwget https:\u002F\u002Fgithub.com\u002Fmicrosoft\u002FBringing-Old-Photos-Back-to-Life\u002Freleases\u002Fdownload\u002Fv1.0\u002Fglobal_checkpoints.zip\nunzip global_checkpoints.zip\ncd ..\u002F\n```\n\nInstall dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n## :rocket: How to use?\n\n**Note**: GPU can be set 0 or 0,1,2 or 0,2; use -1 for CPU\n\n### 1) Full Pipeline\n\nYou could easily restore the old photos with one simple command after installation and downloading the pretrained model.\n\nFor images without scratches:\n\n```\npython run.py --input_folder [test_image_folder_path] \\\n              --output_folder [output_path] \\\n              --GPU 0\n```\n\nFor scratched images:\n\n```\npython run.py --input_folder [test_image_folder_path] \\\n              --output_folder [output_path] \\\n              --GPU 0 \\\n              --with_scratch\n```\n\n**For high-resolution images with scratches**:\n\n```\npython run.py --input_folder [test_image_folder_path] \\\n              --output_folder [output_path] \\\n              --GPU 0 \\\n              --with_scratch \\\n              --HR\n```\n\nNote: Please try to use the absolute path. The final results will be saved in `.\u002Foutput_path\u002Ffinal_output\u002F`. You could also check the produced results of different steps in `output_path`.\n\n### 2) Scratch Detection\n\nCurrently 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.\n\n```\ncd Global\u002F\npython detection.py --test_path [test_image_folder_path] \\\n                    --output_dir [output_path] \\\n                    --input_size [resize_256|full_size|scale_256]\n```\n\n\u003Cimg src='imgs\u002Fscratch_detection.png'>\n\n### 3) Global Restoration\n\nA triplet domain translation network is proposed to solve both structured degradation and unstructured degradation of old photos.\n\n\u003Cp align=\"center\">\n\u003Cimg src='imgs\u002Fpipeline.PNG' width=\"50%\" height=\"50%\"\u002F>\n\u003C\u002Fp>\n\n```\ncd Global\u002F\npython test.py --Scratch_and_Quality_restore \\\n               --test_input [test_image_folder_path] \\\n               --test_mask [corresponding mask] \\\n               --outputs_dir [output_path]\n\npython test.py --Quality_restore \\\n               --test_input [test_image_folder_path] \\\n               --outputs_dir [output_path]\n```\n\n\u003Cimg src='imgs\u002Fglobal.png'>\n\n\n### 4) Face Enhancement\n\nWe use a progressive generator to refine the face regions of old photos. More details could be found in our journal submission and `.\u002FFace_Enhancement` folder.\n\n\u003Cp align=\"center\">\n\u003Cimg src='imgs\u002Fface_pipeline.jpg' width=\"60%\" height=\"60%\"\u002F>\n\u003C\u002Fp>\n\n\n\u003Cimg src='imgs\u002Fface.png'>\n\n> *NOTE*: \n> This repo is mainly for research purpose and we have not yet optimized the running performance. \n> \n> Since the model is pretrained with 256*256 images, the model may not work ideally for arbitrary resolution.\n\n### 5) GUI\n\nA user-friendly GUI which takes input of image by user and shows result in respective window.\n\n#### How it works:\n\n1. Run GUI.py file.\n2. Click browse and select your image from test_images\u002Fold_w_scratch folder to remove scratches.\n3. Click Modify Photo button.\n4. Wait for a while and see results on GUI window.\n5. Exit window by clicking Exit Window and get your result image in output folder.\n\n\u003Cimg src='imgs\u002Fgui.PNG'>\n\n## How to train?\n\n### 1) Create Training File\n\nPut the folders of VOC dataset, collected old photos (e.g., Real_L_old and Real_RGB_old) into one shared folder. Then\n```\ncd Global\u002Fdata\u002F\npython Create_Bigfile.py\n```\nNote: Remember to modify the code based on your own environment.\n\n### 2) Train the VAEs of domain A and domain B respectively\n\n```\ncd ..\npython 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]\n\npython 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]\n```\nNote: For the --name option, please ensure your experiment name contains \"domainA\" or \"domainB\", which will be used to select different dataset.\n\n### 3) Train the mapping network between domains\n\nTrain the mapping without scratches:\n```\npython 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]\n```\n\n\nTraing the mapping with scraches:\n```\npython 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]\n```\n\nTraing the mapping with scraches (Multi-Scale Patch Attention for HR input):\n```\npython 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\n```\n\n\n## Citation\n\nIf you find our work useful for your research, please consider citing the following papers :)\n\n```bibtex\n@inproceedings{wan2020bringing,\ntitle={Bringing Old Photos Back to Life},\nauthor={Wan, Ziyu and Zhang, Bo and Chen, Dongdong and Zhang, Pan and Chen, Dong and Liao, Jing and Wen, Fang},\nbooktitle={Proceedings of the IEEE\u002FCVF Conference on Computer Vision and Pattern Recognition},\npages={2747--2757},\nyear={2020}\n}\n```\n\n```bibtex\n@article{wan2020old,\n  title={Old Photo Restoration via Deep Latent Space Translation},\n  author={Wan, Ziyu and Zhang, Bo and Chen, Dongdong and Zhang, Pan and Chen, Dong and Liao, Jing and Wen, Fang},\n  journal={arXiv preprint arXiv:2009.07047},\n  year={2020}\n}\n```\n\nIf you are also interested in the legacy photo\u002Fvideo colorization, please refer to [this work](https:\u002F\u002Fgithub.com\u002Fzhangmozhe\u002Fvideo-colorization).\n\n## Maintenance\n\nThis project is currently maintained by Ziyu Wan and is for academic research use only. If you have any questions, feel free to contact raywzy@gmail.com.\n\n## License\n\nThe 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.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002F). For more information see the [Code of Conduct FAQ](https:\u002F\u002Fopensource.microsoft.com\u002Fcodeofconduct\u002Ffaq\u002F) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","该项目旨在通过深度学习技术恢复旧照片，使其焕然一新。它基于生成对抗网络（GANs）和图像修复技术，能够处理包括颜色增强、划痕去除在内的多种图像问题。项目使用PyTorch框架实现，并提供了预训练模型以及Colab演示，便于用户快速上手体验。适合历史档案数字化、家庭相册翻新等场景应用，同时也为相关领域的研究人员提供了一个强大的实验平台。","2026-06-11 03:33:54","high_star"]