Ubuntu+AMD显卡搭建Real-ESRGAN

目前只在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
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值