Ubuntu+AMD显卡搭建Real-ESRGAN

本文介绍了如何在Ubuntu20.04系统上,利用ROCM5.2和root权限搭建Real-ESRGAN,包括安装PyTorch和其他依赖库,如BasicsR、FaceXLib和GFPGAN。该过程适用于AMD显卡,并提供了命令行步骤来执行图像和视频的修复与增强操作。
摘要由CSDN通过智能技术生成

目前只在Ubuntu20.04+rocm5.2上搭建成功,需要切换到root权限搭建,否则Real-ESRGAN会自动下载nvidia的驱动(可能需要添加到环境变量中),搭建链接:Ubuntu22.04安装AMD显卡驱动和pytorch_V2077的博客-CSDN博客,项目链接:GitHub - xinntao/Real-ESRGAN: Real-ESRGAN aims at developing Practical Algorithms for General Image/Video Restoration.

 安装Real-ESRGAN

$ cd ~
$ git clone https://github.com/xinntao/Real-ESRGAN.git
$ cd Real-ESRGAN

# 安装 basicsr - https://github.com/xinntao/BasicSR
# 我们使用BasicSR来训练以及推断
$ pip install basicsr
# facexlib和gfpgan是用来增强人脸的
$ pip install facexlib
$ pip install gfpgan
$ pip install -r requirements.txt
$ sudo python3 setup.py develop

 图片修复

sudo python3 inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhance

视频修复

安装

sudo apt-get -y install ffmpeg && pip3 install ffmpeg

 修复

# rmvb转mp4
$ ffmpeg -i [inputname].rmvb -c:v libx264 -strict -2 [outputname].mp4

$ sudo python3 inference_realesrgan_video.py -n RealESRGAN_x4plus -i inputs.mp4 --face_enhance

或者

$ ffmpeg -i input.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 ./inputs/frame%08d.jpg
$ sudo python3 inference_realesrgan.py -n RealESRGAN_x4plus -i inputs --face_enhance
$ ffmpeg -i ./results/frame%08d_out.jpg -i input.mp4 -map 0:v:0 -map 1:a:0 -c:a copy -c:v libx264 -r 23.98 -pix_fmt yuv420p output.mp4

Python 脚本的用法 

Usage: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile -o outfile [options]...

A common command: python inference_realesrgan.py -n RealESRGAN_x4plus -i infile --outscale 3.5 --face_enhance

  -h                   show this help
  -i --input           Input image or folder. Default: inputs
  -o --output          Output folder. Default: results
  -n --model_name      Model name. Default: RealESRGAN_x4plus
  -s, --outscale       The final upsampling scale of the image. Default: 4
  --suffix             Suffix of the restored image. Default: out
  -t, --tile           Tile size, 0 for no tile during testing. Default: 0
  --face_enhance       Whether to use GFPGAN to enhance face. Default: False
  --fp32               Use fp32 precision during inference. Default: fp16 (half precision).
  --ext                Image extension. Options: auto | jpg | png, auto means using the same extension as inputs. Default: auto

模型下载:

  1. RealESRGAN_x4plus
  2. RealESRNet_x4plus
  3. RealESRGAN_x2plus
  4. realesr-animevideov3
  5. RealESRGAN_x4plus_anime_6B
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Real-ESRGAN是一种超分辨率网络,全称为Enhanced Super-Resolution Generative Adversarial Networks。该网络通过训练以PSNR为导向的Real-ESRNet模型,然后以Real-ESRNet的网络参数进行初始化,同时使用L1 loss、perceptual loss和GAN loss作为损失函数来训练最终的Real-ESRGAN网络。 Real-ESRGAN被用作一种图像分辨率修复工具,可以提升照片和动画图片的分辨率。它内置了一个预训练模型,能够将分辨率提高到原来的4倍。虽然Real-ESRGAN是一个命令行工具,但使用起来非常简单,而且效果也非常好。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Real-ESRGAN超分辨网络](https://blog.csdn.net/weixin_46515047/article/details/119829454)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [Real-ESRGAN 深度学习超分辨率重建工具](https://download.csdn.net/download/hq10086/79831404)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值