A Video Upscaler script based on GFPGAN.
Compare to Real-ESRGAN, GFPGAN can restore faces nicely. But, it gonna be very very slow. Only use it for short videos.
This script is modified from
https://github.com/GeeveGeorge/GFPGAN-for-Video-SR
Working with torch 2.x
part of this document)Real-ESRGAN
with command pip install realesrgan
in your python environmentYour GFPGAN Folder/gfpgan/weights
Your GFPGAN Folder/gfpgan/weights
Your GFPGAN Folder/gfpgan/weights
video.py
file from this project, put it into your GFPGAN
folderdata
folder under your GFPGAN
folderGFPGAN
foldervideo.py
, modify its fps and upscale size for your video and save file.python video.py
and wait.GFPGAN/data/results_mp4_videos
If you see any ffmpeg error msg like Format avi detected only with low score of 1, misdetection possible
, that's not the real error.
The real issue is your GFPGAN failed. So ffmpeg can not get the result video it need. The real error msg, is the line before walking
.
A basic rule for this project is: if your GFPGAN works, this project works. If your GFPGAN fails, this project fails too. So you better check following issues of GFPGAN.
Your file and folder path should only use English character without any space in it.
When using GFPGAN for the first time, it gonna download some models from github. One for Real-ESRGAN
, others for GFPGAN
. If downloading failed, it will show the downloading link and its target local folder path. So you can just manually download these models and put them into the right folder.
torchvision.transforms.functional_tensor
GFPGAN is based on a project called basicsr
. This project uses function torchvision.transforms.functional_tensor
which is removed from torchvision v0.17+. So, it only works with pytorch 1.x.
You need to install torch 2.x by following its official installation document: https://pytorch.org/get-started/locally/
You need to update your package basicsr
. Which is needed by GFPGAN, but only works with pytorch 1.x if you install it with pip.
There are 2 ways to make it work with torch 2.x.
basicsr/data/degradations.py
, replace all torchvision.transforms.functional_tensor
with torchvision.transforms.functional
. basicsr
with pip server, which is an old version. Just install it from its source code:pip install git+https://github.com/XPixelGroup/BasicSR