微软开源AI修图工具让老照片重现生机

这篇具有很好参考价值的文章主要介绍了微软开源AI修图工具让老照片重现生机。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

GitHub - microsoft/Bringing-Old-Photos-Back-to-Life: Bringing Old Photo Back to Life (CVPR 2020 oral)

支持划痕修复,以及模型训练。

Old Photo Restoration (Official PyTorch Implementation)

微软开源AI修图工具让老照片重现生机

Project Page | Paper (CVPR version) | Paper (Journal version) | Pretrained Model | Colab Demo | Replicate Demo & Docker Image 🔥

Bringing Old Photos Back to Life, CVPR2020 (Oral)

Old Photo Restoration via Deep Latent Space Translation, TPAMI 2022

Ziyu Wan1, Bo Zhang2, Dongdong Chen3, Pan Zhang4, Dong Chen2, Jing Liao1, Fang Wen2
1City University of Hong Kong, 2Microsoft Research Asia, 3Microsoft Cloud AI, 4USTC

✨ News

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 and github repo.

The framework now supports the restoration of high-resolution input.

微软开源AI修图工具让老照片重现生机

Training code is available and welcome to have a try and learn the training details.

You can now play with our Colab 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, 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://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/face_checkpoints.zip
unzip face_checkpoints.zip
cd ../
cd Global/
wget https://github.com/microsoft/Bringing-Old-Photos-Back-to-Life/releases/download/v1.0/global_checkpoints.zip
unzip global_checkpoints.zip
cd ../

Install dependencies:

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

For high-resolution images with scratches:

python run.py --input_folder [test_image_folder_path] \
              --output_folder [output_path] \
              --GPU 0 \
              --with_scratch \
              --HR

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]

微软开源AI修图工具让老照片重现生机

3) Global Restoration

A triplet domain translation network is proposed to solve both structured degradation and unstructured degradation of old photos.

微软开源AI修图工具让老照片重现生机

cd Global/
python test.py --Scratch_and_Quality_restore \
               --test_input [test_image_folder_path] \
               --test_mask [corresponding mask] \
               --outputs_dir [output_path]

python test.py --Quality_restore \
               --test_input [test_image_folder_path] \
               --outputs_dir [output_path]

微软开源AI修图工具让老照片重现生机

4) Face Enhancement

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.

微软开源AI修图工具让老照片重现生机

微软开源AI修图工具让老照片重现生机

NOTE: This repo is mainly for research purpose and we have not yet optimized the running performance.

Since the model is pretrained with 256*256 images, the model may not work ideally for arbitrary resolution.

5) GUI

A user-friendly GUI which takes input of image by user and shows result in respective window.

How it works:

  1. Run GUI.py file.
  2. Click browse and select your image from test_images/old_w_scratch folder to remove scratches.
  3. Click Modify Photo button.
  4. Wait for a while and see results on GUI window.
  5. Exit window by clicking Exit Window and get your result image in output folder.

How to train?

1) Create Training File

Put the folders of VOC dataset, collected old photos (e.g., Real_L_old and Real_RGB_old) into one shared folder. Then

cd Global/data/
python Create_Bigfile.py

Note: Remember to modify the code based on your own environment.

2) Train the VAEs of domain A and domain B respectively

cd ..
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]

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]

Note: For the --name option, please ensure your experiment name contains "domainA" or "domainB", which will be used to select different dataset.

3) Train the mapping network between domains

Train the mapping without scratches:

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]

Traing the mapping with scraches:

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]

Traing the mapping with scraches (Multi-Scale Patch Attention for HR input):

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

Citation

If you find our work useful for your research, please consider citing the following papers :)

@inproceedings{wan2020bringing,
title={Bringing Old Photos Back to Life},
author={Wan, Ziyu and Zhang, Bo and Chen, Dongdong and Zhang, Pan and Chen, Dong and Liao, Jing and Wen, Fang},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={2747--2757},
year={2020}
}
@article{wan2020old,
  title={Old Photo Restoration via Deep Latent Space Translation},
  author={Wan, Ziyu and Zhang, Bo and Chen, Dongdong and Zhang, Pan and Chen, Dong and Liao, Jing and Wen, Fang},
  journal={arXiv preprint arXiv:2009.07047},
  year={2020}
}

If you are also interested in the legacy photo/video colorization, please refer to this work.

Maintenance

This 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.

License

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.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

在线测试demo

microsoft/bringing-old-photos-back-to-life – Run with an API on Replicate

效果还是有限,需要人工介入

微软开源AI修图工具让老照片重现生机文章来源地址https://www.toymoban.com/news/detail-451892.html

到了这里,关于微软开源AI修图工具让老照片重现生机的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • AI绘图实战(五):放大并修复老照片、马赛克照片、身份证件照 | Stable Diffusion成为设计师生产力工具

    S:你安装stable diffusion就是为了看小姐姐么? I :当然不是,当然是为了公司的发展谋出路~~ 预先学习 : 安装及其问题解决参考:《Windows安装Stable Diffusion WebUI及问题解决记录》; 运行使用时问题《Windows使用Stable Diffusion时遇到的各种问题整理》; 模型运用及参数《Stable D

    2024年02月01日
    浏览(60)
  • AI老照片上色-DeOldify

     🏡 个人主页:IT贫道-CSDN博客  🚩 私聊博主:私聊博主加WX好友,获取更多资料哦~  🔔 博主个人B栈地址:豹哥教你学编程的个人空间-豹哥教你学编程个人主页-哔哩哔哩视频 目录 1. 老照片上色原理 2. 老照片上色环境准备 2.1 下载DeOldify项目 2.2 下载权重文件 2.3 安装依

    2024年01月20日
    浏览(48)
  • Python开源项目之人工智能老照片修复算法学习

    老旧或者破损的照片如何修复呢?本文主要分享一个博主使用后非常不错的照片恢复开源项目:Bringing-Old-Photos-Back-to-Life。 项目的Github地址:项目地址 我们先看看官方给出的效果图: 就算现在看到这张图,我仍然觉着非常惊艳。下面我会把项目环境安装部署,到最后使用的

    2024年02月03日
    浏览(70)
  • 〔AI 绘画〕Stable Diffusion 之 老照片高清修复 篇

    在 AI 绘画出来后,飞兔小哥就一直思考它的商业出路,其中之一应用我觉得就是老照片修复 其实在 stable diffusion 中修复老照片,其实有很好的效果,根据目前其内置的功能,大概有三种可用的高清修复功能 而飞兔小哥也在社区开了相应的 AI 专栏,并将自己平时生成和修复处

    2024年02月13日
    浏览(116)
  • AI 绘画Stable Diffusion 研究(九)sd图生图功能详解-老照片高清修复放大

    大家好,我是风雨无阻。 通过前面几篇文章的介绍,相信各位小伙伴,对 Stable Diffusion 这款强大的AI 绘图系统有了全新的认知。我们见识到了借助 Stable Diffusion的文生图功能,利用简单的几个单词,就可以生成完美的图片。本期我们一起来研究 Stable Diffusion图生图功能这个宝

    2024年02月12日
    浏览(79)
  • 来自腾讯AI实验室的Real-ESRGAN将模糊老照片和视频修复成高清晰(一些错误处理)

            Real-ESRGAN:Enhanced Super-Resolution GAN: 增强的超分辨率的对抗生成网络 ,对于GAN相信大家都比较熟悉,前有阿尔法狗,现有很多GAN的延伸版本,StyleGAN1~3系列以及DragGAN对于图片的生成和编辑,出来的效果都很惊艳。         一些旧照片,时代比较久远了,那个时候

    2024年02月08日
    浏览(71)
  • Stable Diffusion 黑白老照片上色修复

            在这个时代,我们习惯于拥有高清、色彩丰富的照片,然而,那些古老的黑白色老照片由于年代的久远,往往会出现模糊、破损等现象。         那么今天要给大家介绍的是,用 Stable Diffusion 来修复老照片。         前段时间 ControlNet 的除了上线了“IP

    2024年01月22日
    浏览(53)
  • Stable Diffusion高清修复老照片-图生图

    修复老照片的意义就不多说了,相信大家都明白,这里直接开讲方法。 1、原理 这个方法需要一个真实模型,以便让修复的照片看起来比较真实,我这里选择:realisticVisionV20,大家有更好的给我推荐哦。 还需用搭配两个特殊设置: ControlNet Tile:这是一个ControlNet模型,用于放

    2024年02月14日
    浏览(44)
  • 〔009〕Stable Diffusion 之 老照片高清修复 篇

    在 AI 绘画出来后,飞兔小哥就一直思考它的商业出路,其中之一应用我觉得就是老照片修复 其实在 stable diffusion 中修复老照片,其实有很好的效果,根据目前其内置的功能,大概有三种可用的高清修复功能 而飞兔小哥也在社区开了相应的 AI 专栏,并将自己平时生成和修复处

    2024年02月11日
    浏览(54)
  • 【stable diffusion 老照片修复---张自忠将军】

    text 2 image: Prompt: masterpiece, best quality, extremely detailed , 2k wallpaper, extremely detailed CG unity 8k wallpaper, extremely detailed, intricate detail,chinese,man,a younger general of chinese army,looking camera, 25 years old,green uniform, live eyes Negative prompt: paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), low

    2024年02月12日
    浏览(46)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包