Jizhi AI | AI algorithm repairs old photos of the last century and returns your ancestors' memories

欢迎关注我的公众号 [极智视界],获取我的更多笔记分享

  Hello everyone, I am Jizhi Vision. This article introduces the method of using AI algorithm to repair blurred old photos.

  The Tang, Song, Yuan, Ming, Qing, and Qing dynasties (1636-1912) were the last feudal dynasty in Chinese history, with a total of twelve emperors. The ruler is Aisin Gioro. From the establishment of Nurhaci after Jin, a total of 296 years; from the time when Huang Taiji changed the country's name to Qing, Guozuo 276 years. Qing, is it like this in your memory:

  The Qing Dynasty is so far away in our memory that it seems that only some scenes can be evoked from ruins , archaeology , and treasures . But the reality 2022 - 1912 is only 110 years away. This can easily lead to thinking, what will people leave behind after a hundred years of life? People who like to study history and astronomy must understand that human beings are so small and short-lived, so how to make good use of their limited life is particularly important.

  The September 18th Incident in 1931 was the beginning of the Anti-Japanese War. It was an unbearable memory. The compatriots were tortured and humiliated, but the Chinese children were stubborn and won a complete victory in the Anti-Japanese War in 1945. This red memory may be Such:

  Let's count 2022 - 1945 = 77 years, and it is only 77 years. We have to sigh the development momentum brought by reform and opening up and one country , two systems to New China. The current peace and better life are really hard-won.

  In modern life, technology really makes life more and more beautiful. Mobile phones with better and better performance, cameras with higher and higher definition, and a variety of rich sensors, clearly record every bit of our life . The support behind clear picture, clear video screen, and clear voice is the continuous advancement of sensor hardware and the continuous upgrading of image processing algorithms. With the continuous improvement of AI algorithms, we can now use AI algorithms to repair our **"fuzzy memory"**, and the effect is quite good. As you may have heard 清朝的黑白录像彩色化, 静态的人像眼睛一眨一眨笑起来了these are the capabilities of AI.

  GAN network is a very interesting algorithm that can do many interesting things, such as: generating portraits with different styles, animation of portraits, changing your hairstyle, what you will look like after gender swap, if you are Indian, you What does the president look like, etc., of course, including the blurring of our portraits .

  Here we use the GAN algorithm. If you want the project source code, you can click here . The architecture of the entire network is as follows:

  The network mainly consists of two modules:

  • (1) Dedegradation module: a Unet;
  • (2) Prior pre-training GAN module: a StyleGAN2;

  The two modules are connected by channel segmentation-based spatial feature transformation (CS-SFT), the de-degradation module maps the latent features to the latent feature space of the pre-trained StyleGAN2, the multi-resolution features modulate StyleGAN2 from coarse to fine, and the loss function In addition to the traditional adversarial loss, face component loss, identity fidelity loss, and de-degenerate module reconstruction loss are added.

  After we get the project, install the dependent environment first:

# Install basicsr - https://github.com/xinntao/BasicSR
# use BasicSR for both training and inference
pip install basicsr

# Install facexlib - https://github.com/xinntao/facexlib
# use face detection and face restoration helper in the facexlib package
pip install facexlib

pip install -r requirements.txt
python setup.py develop

# If you want to enhance the background (non-face) regions with Real-ESRGAN,
# you also need to install the realesrgan package
pip install realesrgan
复制代码

  Then you can click README.mdto download the pre-training weights, or you can directly use the following command:

wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models
复制代码

  Then inference verification can be done:

python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2
复制代码

  Some of these parameters are explained as follows:

Usage: python inference_gfpgan.py -i inputs/whole_imgs -o results -v 1.3 -s 2 [options]...

  -h                   show this help
  -i input             Input image or folder. Default: inputs/whole_imgs
  -o output            Output folder. Default: results
  -v version           GFPGAN model version. Option: 1 | 1.2 | 1.3. Default: 1.3
  -s upscale           The final upsampling scale of the image. Default: 2
  -bg_upsampler        background upsampler. Default: realesrgan
  -bg_tile             Tile size for background sampler, 0 for no tile during testing. Default: 400
  -suffix              Suffix of the restored faces
  -only_center_face    Only restore the center face
  -aligned             Input are aligned faces
  -ext                 Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto
复制代码

  Let's show the effect with some pictures:

  It can be seen that the portrait deblurring effect is still very good.

  At this time, should you move your little hand, take out old photos, practice it, and see the effect~


  Well, the above shared the method of explaining the AI ​​algorithm to repair old photos. I hope my sharing can help you a little bit in your study.



 【Public number transmission】

"Extremely Intelligent AI | AI Algorithm Repairs Old Photos of the Last Century and Returns Your Grandfather's Memories"


logo_show.gif

Guess you like

Origin juejin.im/post/7119420598123495460