View Full Version : VSGAN - VapourSynth GAN Implementation, based on ESRGAN's implementation
Selur
19th August 2021, 16:16
Yup, some tiling would to keep the memory consumption low would be nice.
Selur
4th October 2021, 19:01
Hmm, wrote a small script that splits an image into tileCount*tileCount tiles and applies vsgan on each of them.
import vapoursynth as vs
from vapoursynth import core
from vsgan import VSGAN
import torch
# clip: the video source
# model: path to the model to callable
# tileCount number of times source will be splitt horizontally and vertically
def tileVSGAN(clip, tileCount = 8, model = None) -> vs.VideoNode:
if not isinstance(clip, vs.VideoNode):
raise vs.Error('tileVSGAN: clip must be an instance of vs.VideoNode')
if clip.format.id != vs.RGB24:
raise vs.Error('tileVSGAN: clip must be RGB24')
if model == None:
raise vs.Error('tileVSGAN: model needs to be specified')
if tileCount%2 != 0:
raise vs.Error('tileVSGAN: tileCount needs to dividiable by 2.')
if clip.width%(tileCount*2) != 0:
raise vs.Error('tileVSGAN: clip.width must be dividable by 2*tileCount without rest')
if clip.width%(tileCount*2) != 0:
raise vs.Error('tileVSGAN: clip.height must be dividable by 2*tileCount without rest')
tileWidth = clip.width/tileCount
tileHeight = clip.height/tileCount
tiles = [[None for x in range(tileCount)] for y in range(tileCount)]
for index1 in range (tileCount): # vertical
for index2 in range (tileCount): # horizontal
tile = core.std.CropRel(clip=clip, left=tileWidth*index2, right = tileWidth*(tileCount-index2-1), top=tileHeight*index1, bottom=tileHeight*(tileCount-index1-1))
#tiles[index1][index2] = core.text.Text(clip=tile,text=str(index1)+'/'+str(index2),scale=1)
# apply VSGAN on each tile
for index1 in range (tileCount): # vertical
for index2 in range (tileCount): # horizontal
vsgan = VSGAN("cuda")
vsgan.load_model(model)
tiles[index1][index2] = vsgan.run(clip=tiles[index1][index2])
del vsgan # delete vsgan object
torch.cuda.empty_cache() # trigger pytorch to free gpu memory cache
horizontal = [None for x in range(tileCount)]
for index in range (tileCount):
horizontal[index] = core.std.StackHorizontal(tiles[index])
clip = core.std.StackVertical(horizontal)
return clip
the intention was that running vsgan on lower resolution images should require less vram.
Problem is that is doesn't seem to work, even with tileCount 64 on 4k content all my 8GB VRAM is full. :/
Cu Selur
_Al_
5th October 2021, 02:02
unfortunately I do not have VSGAN to test it, but what about this, trying to process one clip at a time, put it more into functions so things get garbage collected:
def clipVSGAN(clip, model):
vsgan = VSGAN("cuda")
vsgan.load_model(model)
new_clip = vsgan.run(clip=clip)
del vsgan # delete vsgan object
torch.cuda.empty_cache() # trigger pytorch to free gpu memory cache
return new_clip
def tileVSGAN(clip, tileCount = 8, model = None) -> vs.VideoNode:
if not isinstance(clip, vs.VideoNode):
raise vs.Error('tileVSGAN: clip must be an instance of vs.VideoNode')
if clip.format.id != vs.RGB24:
raise vs.Error('tileVSGAN: clip must be RGB24')
if model == None:
raise vs.Error('tileVSGAN: model needs to be specified')
if tileCount%2 != 0:
raise vs.Error('tileVSGAN: tileCount needs to dividiable by 2.')
if clip.width%(tileCount*2) != 0:
raise vs.Error('tileVSGAN: clip.width must be dividable by 2*tileCount without rest')
if clip.width%(tileCount*2) != 0:
raise vs.Error('tileVSGAN: clip.height must be dividable by 2*tileCount without rest')
def fetch_new_tile(clip, tileWidth, tileHeight, tileCount):
for index1 in range (tileCount): # vertical
for index2 in range (tileCount): # horizontal
tile = core.std.CropRel(clip = clip,
left = tileWidth*index2,
right = tileWidth*(tileCount-index2-1),
top = tileHeight*index1,
bottom = tileHeight*(tileCount-index1-1)
)
yield clipVSGAN(tile, model)
del tile
tileWidth = clip.width/tileCount
tileHeight = clip.height/tileCount
tiles = [[None for x in range(tileCount)] for y in range(tileCount)]
new_tile_generator = fetch_new_tile(clip, tileWidth, tileHeight, tileCount)
for index1 in range (tileCount):
for index2 in range (tileCount):
tiles[index1][index2] = next(new_tile_generator)
horizontal = [None for x in range(tileCount)]
for index in range (tileCount):
horizontal[index] = core.std.StackHorizontal(tiles[index])
clip = core.std.StackVertical(horizontal)
return clip
poisondeathray
5th October 2021, 14:31
There are several tiling scripts with variable input size and padding/margins out there
eg
https://github.com/Oriode/ESRGAN-Tiling-Script/blob/master/upscale.py
They just need to be "massaged" into vapoursynth form .
Several of HolyWu's scripts have tiling/padding too. HolyWu could probably add it easily
Selur
5th October 2021, 18:00
@_Al_: doesn't seem to behave differntly
RuntimeError: CUDA out of memory. Tried to allocate 2.00 MiB (GPU 0; 8.00 GiB total capacity; 6.75 GiB already allocated; 0 bytes free; 6.90 GiB reserved in total by PyTorch)
So if someone comes up with a working way to use this please share. :)
Cu Selur
_Al_
5th October 2021, 21:34
https://github.com/rlaphoenix/VSGAN/blob/master/vsgan/__init__.py
PRAGMA had implemented that already, his parameter chunk in run()
def run(self, clip: vs.VideoNode, chunk: bool = False) -> vs.VideoNode:
chunk=True would split clip to quadrants
def chunk(self, clip: vs.VideoNode) -> Iterable[vs.VideoNode]:
"""
Split clip down the center into two clips (a left and right clip)
Then split those 2 clips in the center into two clips (a top and bottom clip).
Resulting in a total of 4 clips (aka chunk).
"""
return itertools.chain.from_iterable([
self.split(x, axis=1) for x in self.split(clip, axis=0)
])
that function would need to be changed to return list of tiles
then he is reassembling clips doing this:
# if chunked, rejoin the chunked clips otherwise return the result
clip = core.std.StackHorizontal([
core.std.StackVertical([results[0], results[1]]),
core.std.StackVertical([results[2], results[3]])
]) if chunk else results[0]
that would need to be changed to reassemble it same way as it was chopped off
but there is a concern, because that poissondeathray link workflow uses margins, which they are cut off before assembling tiles, probably if not done, borders could be visible with some artifacts
poisondeathray
6th October 2021, 00:08
but there is a concern, because that poissondeathray link workflow uses margins, which they are cut off before assembling tiles, probably if not done, borders could be visible with some artifacts
Yes, you need padding, otherwise you get artifacts. Quality loss is negligible if padding is large enough (but detectable with metrics or amplified differences - you see the split lines, but invisible to human eye)
PRAGMA
6th October 2021, 21:35
https://github.com/rlaphoenix/VSGAN/blob/master/vsgan/__init__.py
PRAGMA had implemented that already, his parameter chunk in run()
def run(self, clip: vs.VideoNode, chunk: bool = False) -> vs.VideoNode:
chunk=True would split clip to quadrants
def chunk(self, clip: vs.VideoNode) -> Iterable[vs.VideoNode]:
"""
Split clip down the center into two clips (a left and right clip)
Then split those 2 clips in the center into two clips (a top and bottom clip).
Resulting in a total of 4 clips (aka chunk).
"""
return itertools.chain.from_iterable([
self.split(x, axis=1) for x in self.split(clip, axis=0)
])
that function would need to be changed to return list of tiles
then he is reassembling clips doing this:
# if chunked, rejoin the chunked clips otherwise return the result
clip = core.std.StackHorizontal([
core.std.StackVertical([results[0], results[1]]),
core.std.StackVertical([results[2], results[3]])
]) if chunk else results[0]
that would need to be changed to reassemble it same way as it was chopped off
but there is a concern, because that poissondeathray link workflow uses margins, which they are cut off before assembling tiles, probably if not done, borders could be visible with some artifacts
Hi, yeah, it has support for this but generally speaking I advise people not to use it because the current way it works isnt as unnoticeable as other solutions can return.
I could probably work on adding some black padding fairly easily to each one, and then crop if that works well enough. I see selur made an issue post asking for it, so if I ever work on it I will push updates there. https://github.com/rlaphoenix/VSGAN/issues/9
PRAGMA
6th October 2021, 21:43
I updated the Installation docs page to add some small information about how to use python/pip on a portable installation. Some users here struggled with that.
I also created a new troubleshooting page with some solutions or advice to problems posted in pages 2 and 3.
zorr
6th October 2021, 22:53
I believe padding with black is not going to help, rather it needs the surrounding image data. Kind of like MVTools overlap.
Selur
7th October 2021, 04:38
New problem,...
I updated VSGAN:
I:\Hybrid\64bit\Vapoursynth>python -m pip install --upgrade vsgan
Requirement already satisfied: vsgan in i:\hybrid\64bit\vapoursynth\lib\site-packages (1.2.1)
Collecting vsgan
Downloading vsgan-1.3.0-py3-none-any.whl (10 kB)
Collecting torch<2.0.0,>=1.9.1
Using cached torch-1.9.1-cp39-cp39-win_amd64.whl (222.0 MB)
Collecting numpy==1.19.5
Downloading numpy-1.19.5-cp39-cp39-win_amd64.whl (13.3 MB)
|████████████████████████████████| 13.3 MB 2.2 MB/s
Requirement already satisfied: typing-extensions in i:\hybrid\64bit\vapoursynth\lib\site-packages (from torch<2.0.0,>=1.9.1->vsgan) (3.10.0.2)
Installing collected packages: torch, numpy, vsgan
Attempting uninstall: torch
Found existing installation: torch 1.9.0+cu111
Uninstalling torch-1.9.0+cu111:
Successfully uninstalled torch-1.9.0+cu111
WARNING: The scripts convert-caffe2-to-onnx.exe and convert-onnx-to-caffe2.exe are installed in 'I:\Hybrid\64bit\Vapoursynth\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Attempting uninstall: numpy
Found existing installation: numpy 1.21.2
Uninstalling numpy-1.21.2:
Successfully uninstalled numpy-1.21.2
WARNING: The script f2py.exe is installed in 'I:\Hybrid\64bit\Vapoursynth\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Attempting uninstall: vsgan
Found existing installation: vsgan 1.2.1
Uninstalling vsgan-1.2.1:
Successfully uninstalled vsgan-1.2.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
torchvision 0.10.0+cu111 requires torch==1.9.0, but you have torch 1.9.1 which is incompatible.
torchaudio 0.9.0 requires torch==1.9.0, but you have torch 1.9.1 which is incompatible.
Successfully installed numpy-1.19.5 torch-1.9.1 vsgan-1.3.0
I:\Hybrid\64bit\Vapoursynth>python -m pip install --upgrade vsgan
Requirement already satisfied: vsgan in i:\hybrid\64bit\vapoursynth\lib\site-packages (1.3.0)
Requirement already satisfied: torch<2.0.0,>=1.9.1 in i:\hybrid\64bit\vapoursynth\lib\site-packages (from vsgan) (1.9.1)
Requirement already satisfied: numpy==1.19.5 in i:\hybrid\64bit\vapoursynth\lib\site-packages (from vsgan) (1.19.5)
Requirement already satisfied: typing-extensions in i:\hybrid\64bit\vapoursynth\lib\site-packages (from torch<2.0.0,>=1.9.1->vsgan) (3.10.0.2)
and now I get:
Failed to evaluate the script:
Python exception: VSGAN: Either NVIDIA CUDA or the device (cuda) isn't available.
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 2324, in vapoursynth.vpy_evaluateScript
File "src\cython\vapoursynth.pyx", line 2325, in vapoursynth.vpy_evaluateScript
File "C:\Users\Selur\Desktop\test2.vpy", line 29, in <module>
vsgan = VSGAN("cuda")
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vsgan\__init__.py", line 34, in __init__
raise EnvironmentError("VSGAN: Either NVIDIA CUDA or the device (%s) isn't available." % device)
OSError: VSGAN: Either NVIDIA CUDA or the device (cuda) isn't available.
when calling:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
from vsgan import VSGAN
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
vsgan = VSGAN("cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_BSRGAN.pth"
vsgan.load_model(model)
clip = vsgan.run(clip=clip) # 2560x1408
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=1920, h=1056, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P10 for x265Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output(
Any idea what I can do how to fix this?
Cu Selur
Selur
7th October 2021, 04:52
Okay, fixed it by calling:
python.exe -m pip install torch===1.9.1+cu111 torchvision===0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
Cu Selur
PRAGMA
8th October 2021, 05:39
Okay, fixed it by calling:
python.exe -m pip install torch===1.9.1+cu111 torchvision===0.10.1 -f https://download.pytorch.org/whl/torch_stable.html
Cu Selur
Yes it's a common mistake to let the vsgan deps install torch (which does not include cuda bundled in). However, it would be a mistake to not count pytorch as a dependency.
PyTorch honestly isnt normally meant to have cuda bundled, its just a possible installation method. By default/normally, it expects it installed on the system globally of course, which is why this deps installation *can* work, but wont for a portable install or those who dont want to manually install cuda.
Regardless, I'm glad you have it solved. To reiterate, a new troubleshooting page exists which has this issue listed, if you encounter further issues perhaps refer to it: https://rlaphoenix.github.io/VSGAN/troubleshooting/
PRAGMA
19th December 2021, 08:15
VSGAN 1.4.0 has padded/overlapping chunking support. However, it can now only chunk to 4 quadrants only. Perhaps in the future I will implement the ability to chunk each quadrant as well.
PRAGMA
21st December 2021, 16:56
Chaining models is broken in v1.4.0 due to a FrameEval mistake. Please install from source code or wait for the next version which will be soon hopefully.
Edit: Fixed in 1.4.1
PRAGMA
22nd December 2021, 01:22
RealESRGAN support has been added. It's code is NOT great, but it works. Its basically using new-arch of normal ESRGAN (which is restrictive and annoying) but is necessary for the new models RealESRGAN uses.
It will be in the next release after 1.4.1.
EDIT: Full Real-ESRGAN support, including 2x and 1x scale models is added to code, and it no longer uses new-arch, so it works a lot better now.
It will be in v1.5.0.
poisondeathray
22nd December 2021, 02:19
Thanks for the updates, especially overlap chunking
poisondeathray
27th December 2021, 05:37
Thanks also for A-ESRGAN
https://github.com/aesrgan/A-ESRGAN
v1.5.0 Latest
Adds support for ESRGAN+ models, Real-ESRGAN models (including 2x and 1x if pixel-shuffle was used),
and A-ESRGAN models
PRAGMA
29th December 2021, 09:08
Ok so more updates.
Support for half-accuracy was added to all models. This means you can reduce accuracy, which reduces VRAM in ultimately half, which also increases speed by up to double in some cases. It will decrease the accuracy of course, but yeah. For those with very limited VRAM, half accuracy + seamless chunk mode may help quite a bit. This half mode will be applied when you use load_model with `half=True` and will be added to the next version (probably 1.5.1).
Support for ESRGAN+, Real-ESRGAN, and A-ESRGAN are now supported in v1.5.0. With Real-ESRGAN v2 (basically ultra-lite Real-ESRGAN) coming in the next version.
What may appear in next version, if not then the version after is support for EGVSR, which is an inter-frame architecture taking in data from n neighboring frames. It's still in testing and still being worked on but its going well. It is at a state where basic models work, but detection of arch settings has not been worked on yet.
Once auto-detection of arch settings can be done, support will be added in whatever the next version from then is.
Selur
29th December 2021, 16:15
Nice! Looking forward to it. :)
ReinerSchweinlin
30th December 2021, 13:04
nice :)
From my experience with other FP16 Models, Quality still is fine in most cases - and the speedup (on FP16 2:1 vapable cards like recent AMD, GEN20 RTX..) as well as the halved VRAM needed is a very good thing - rarely turning back to FP32 models these days.
PRAGMA
24th January 2022, 09:05
Ok v1.6.0 has been released, with a fairly big change to how VSGAN is ultimately used. This update includes the previously talked about features like half-precision, Real-ESRGANv2, EGVSR, and more.
There's also an upgraded tiling system that will automatically enable or disable depending on if you need the VRAM or not. It will also recursively tile to reduce VRAM even further (if necessary of course).
Please note though, that EGVSR does not auto-detect settings from the model file yet. So you should manually override any settings that needs it when you load the model for correct results.
For more details see the changelog: https://vsgan.phoeniix.dev/en/stable/changelog.html
poisondeathray
24th January 2022, 15:37
Thanks for adding EGVSR.
Please note though, that EGVSR does not auto-detect settings from the model file yet. So you should manually override any settings that needs it when you load the model for correct results.
Can you explain how to do that ?
I'm getting bizarre results with the "EGVSR_iter420000.pth" model - it looks like some fine grid pattern overlaid
PRAGMA
24th January 2022, 18:18
Thanks for adding EGVSR.
Can you explain how to do that ?
I'm getting bizarre results with the "EGVSR_iter420000.pth" model - it looks like some fine grid pattern overlaid
Refer to https://github.com/rlaphoenix/VSGAN/issues/18
maybe this issue was made by you? not sure.
poisondeathray
24th January 2022, 18:24
Refer to https://github.com/rlaphoenix/VSGAN/issues/18
maybe this issue was made by you? not sure.
Not me, but it's a similar overlay grid pattern
(That guy should IVTC first)
Adding nb=10, degradation="BD" fixes it, thanks
load(r'PATH\EGVSR_iter420000.pth', nb=10, degradation="BD")
Selur
24th January 2022, 19:48
Small question, so when using a ESRGAN,ESRGAN+,Real-ESRGAN or A-ESRGAN model I use
from vsgan import ESRGAN
and when using a EGVSR model I use:
from vsgan import EGVSR
correct?
Also: Does anyone know a source for EGVSR models?
(only one I found so far is from https://github.com/Thmen/EGVSR/tree/master/pretrained_models)
poisondeathray
24th January 2022, 19:59
Small question, so when using a ESRGAN,ESRGAN+,Real-ESRGAN or A-ESRGAN model I use
from vsgan import ESRGAN
and when using a EGVSR model I use:
from vsgan import EGVSR
correct?
Works for me
Also: Does anyone know a source for EGVSR models?
AFAIK there is only 1 model (from the official repo)
Selur
24th January 2022, 21:00
Ah, okay.
Things seem to work fine with ESRGAN models (like BSRGAN), but using:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
from vsgan import EGVSR
vsgan = EGVSR(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_iter420000_EGVSR.pth"
vsgan.load(model, nb=10, degradation="BD", out_nc=3, nf=64)
vsgan.apply() # 2560x1408
clip = vsgan.clip
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=1920, h=1056, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
I run out of VRAM :(
CUDA out of memory. Tried to allocate 56.00 MiB (GPU 0; 8.00 GiB total capacity; 6.62 GiB already allocated; 0 bytes free; 6.76 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
Sadly 'overlap' seems to only be implemented for ESRGAN, since when using "vsgan.apply(overlap=16)" in the above example, I get:
Python exception: apply() got an unexpected keyword argument 'overlap'
Cu Selur
poisondeathray
24th January 2022, 21:15
It looks like tiling is only implemented in ESRGAN + derivatives, but not EGVSR yet
Selur
24th January 2022, 21:31
Okay, also got another issue with the current version.
Using:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
from vsgan import ESRGAN
vsgan = ESRGAN(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_BSRGAN.pth"
vsgan.load(model)
vsgan.apply() # 2560x1408
clip = vsgan.clip
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=640, h=352, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
When I open this, it takes a bit to calculate the first frame during which VRAM usage goes up to the max (8GB) and doesn't go down again and hinders me from looking at another frame. :/
when using "vsgan.apply(overlap=16)" the same happens.
-> at least here the new version does only work for one frame.
I also tried different other models, all seem to have the same effect on my system. :(
I sometimes I can step through a few frames (two work, third always fails), but then vram gets stuck and thats it.
poisondeathray
24th January 2022, 22:11
Selur are you running 1.6.3 ? Maybe some memory release issue - but it seems to work ok for me using ESRGAN (or derivatives). Multiple seeks ok on a resolution that definitely uses tiles
Selur
25th January 2022, 05:41
yes, I'm using VSGAN 1.6.3 (using NVIDIA Game-reay driver version 511.23), after a system restart I can do a few more seeks inside the source, but after a bit vram stays at max until preview crashs. :/
PRAGMA
25th January 2022, 10:46
Ah, okay.
Things seem to work fine with ESRGAN models (like BSRGAN), but using:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
from vsgan import EGVSR
vsgan = EGVSR(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_iter420000_EGVSR.pth"
vsgan.load(model, nb=10, degradation="BD", out_nc=3, nf=64)
vsgan.apply() # 2560x1408
clip = vsgan.clip
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=1920, h=1056, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
I run out of VRAM :(
CUDA out of memory. Tried to allocate 56.00 MiB (GPU 0; 8.00 GiB total capacity; 6.62 GiB already allocated; 0 bytes free; 6.76 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
Sadly 'overlap' seems to only be implemented for ESRGAN, since when using "vsgan.apply(overlap=16)" in the above example, I get:
Python exception: apply() got an unexpected keyword argument 'overlap'
Cu Selur
Hi, There are some problems I've discovered with EGVSR atm. It will take further research and testing than initially expected.
Currently, half accuracy for EGVSR does not work correctly, even with fixes on master atm.
It's also somewhat VRAM intensive due to it essentially storing and running multiple frames (6 in total by default) at a time.
One mistake people are doing is letting VS use the default multi-threading with EGVSR when it should be disabled with `core.num_threads = 1`. Once you do this, it will only run the model on the current frame + n(interval) next frames at a time, instead of e.g. 72 frames with a num_threads of 12.
The fixes I'm speaking of right now are in the GitHub repo, but not in a version yet. You could install it straight from the GitHub master if you want to give it a quick test.
I'm still working on trying to get half-accuracy properly working for EGVSR, and still trying to work on methods to reduce VRAM but sadly it's just not going all that well. It might simply just take a lot of VRAM considering the number of frames the network processes at once.
And as for overlap, yes, it's not implemented in EGVSR at the moment, but perhaps that's something we could try one day to lower VRAM requirements.
Selur
25th January 2022, 15:36
sadly using 'core.num_threads = 1' doesn't help here.
Using:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Limit thread count to 1
core.num_threads = 1
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
from vsgan import EGVSR
vsgan = EGVSR(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_iter420000_EGVSR.pth"
# using model parameters from 4x_iter420000_EGVSR.defaults
vsgan.load(model, nb=10, degradation="BD", out_nc=3, nf=64)
vsgan.apply() # 2560x1408
clip = vsgan.clip
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=1920, h=1056, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
VRAM usage directly jumps to max usage reports:
CUDA out of memory. Tried to allocate 56.00 MiB (GPU 0; 8.00 GiB total capacity; 6.62 GiB already allocated; 0 bytes free; 6.76 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
and is stuck at max vram usage until I close the viewer.
Similar situation when using "core.num_threads = 1" with:
vsgan = ESRGAN(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_BSRGAN.pth"
vsgan.load(model)
vsgan.apply(overlap=16) # 2560x1408
First frame works, vram usage is at max and stays there.
Old version 1.5 version worked fine with the same source and model.
trying to go back to 1.5.0 with
I:\Hybrid\64bit\Vapoursynth>python -m pip install --user --force VSGAN==1.5.0
I get:
Collecting VSGAN==1.5.0
Using cached vsgan-1.5.0-py3-none-any.whl (11 kB)
Collecting numpy<2.0.0,>=1.19.5
Using cached numpy-1.22.1-cp39-cp39-win_amd64.whl (14.7 MB)
Installing collected packages: numpy, VSGAN
ERROR: Exception:
Traceback (most recent call last):
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\cli\base_command.py", line 164, in exc_logging_wrapper
status = run_func(*args)
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
return func(self, options, args)
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\commands\install.py", line 404, in run
installed = install_given_reqs(
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\req\__init__.py", line 73, in install_given_reqs
requirement.install(
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\req\req_install.py", line 765, in install
scheme = get_scheme(
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\locations\__init__.py", line 208, in get_scheme
old = _distutils.get_scheme(
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\locations\_distutils.py", line 130, in get_scheme
scheme = distutils_scheme(dist_name, user, home, root, isolated, prefix)
File "I:\Hybrid\64bit\Vapoursynth\Lib\site-packages\pip\_internal\locations\_distutils.py", line 69, in distutils_scheme
i.finalize_options()
File "distutils\command\install.py", line 274, in finalize_options
File "distutils\command\install.py", line 437, in finalize_other
distutils.errors.DistutilsPlatformError: User base directory is not specified
probably will have to uinstall and reinstall VSGAN to swithc back to 1.5.0, but I'll stick to current 1.6.3 and see whether someone else also has the same problem. :)
Okay,scratch that, I made a backup of my Vapoursynth folder before updating to 1.6.3, using 1.5.0 memory usage with version 1.5.0 and:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
from vsgan import VSGAN
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
vsgan = VSGAN(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_BSRGAN.pth"
vsgan.load_model(model)
vsgan.run(overlap=16) # 2560x1408
clip = vsgan.clip
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=1920, h=1056, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
stays at 3.1GB and while the preview is open and I can again switch between frames. (I kept the 1.6.3 folder so I can switch back easily and test stuff if needed.)
Cu Selur
PRAGMA
25th January 2022, 20:47
Okay, also got another issue with the current version.
Using:
# Imports
import os
import sys
import vapoursynth as vs
# getting Vapoursynth core
core = vs.core
# Import scripts folder
scriptPath = 'I:/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="I:/Hybrid/64bit/vsfilters/SourceFilter/FFMS2/ffms2.dll")
# Import scripts
import mvsfunc
# source: 'G:\TestClips&Co\files\test.avi'
# current color space: YUV420P8, bit depth: 8, resolution: 640x352, fps: 25, color matrix: 470bg, yuv luminance scale: limited, scanorder: progressive
# Loading source using FFMS2
clip = core.ffms2.Source(source="G:/TestClips&Co/files/test.avi",cachefile="E:/Temp/avi_6c441f37d9750b62d59f16ecdbd59393_853323747.ffindex",format=vs.YUV420P8,alpha=False)
# making sure input color matrix is set as 470bg
clip = core.resize.Bicubic(clip, matrix_in_s="470bg",range_s="limited")
# making sure frame rate is set to 25
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Setting color range to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjusting color space from YUV420P8 to RGB24 for vsVSGAN
clip = core.resize.Bicubic(clip=clip, format=vs.RGB24, matrix_in_s="470bg", range_s="limited")
# resizing using VSGAN
from vsgan import ESRGAN
vsgan = ESRGAN(clip=clip,device="cuda")
model = "I:/Hybrid/64bit/vsgan_models/4x_BSRGAN.pth"
vsgan.load(model)
vsgan.apply() # 2560x1408
clip = vsgan.clip
# adjusting resizing
clip = core.fmtc.resample(clip=clip, w=640, h=352, kernel="lanczos", interlaced=False, interlacedd=False)
# adjusting output color from: RGB48 to YUV420P8 for x264Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8, matrix_s="470bg", range_s="limited")
# set output frame rate to 25.000fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=25, fpsden=1)
# Output
clip.set_output()
When I open this, it takes a bit to calculate the first frame during which VRAM usage goes up to the max (8GB) and doesn't go down again and hinders me from looking at another frame. :/
when using "vsgan.apply(overlap=16)" the same happens.
-> at least here the new version does only work for one frame.
I also tried different other models, all seem to have the same effect on my system. :(
I sometimes I can step through a few frames (two work, third always fails), but then vram gets stuck and thats it.
Hi, so, the VRAM requirements are generally high but you shouldn't have this much issues using it on a <480p 4x model scenario. When you say you get stuck or cant render a frame, what exactly is the block? The VRAM seems to stay in use until you try render a new frame, the VRAM seems to clear so fast and then get re-used incredibly quickly.
Have you tried using vs-pipe instead of through vs-edit just to see what performance you actually get from as minimal going on as possible? (`vspipe script.vpy . -p`).
Perhaps try close all VS-edit instances, check the GPU usage has gone down (it will still have a bit loaded by pytorch from some reason), and then reopen and try? Sometimes randomly seeking and clicking play a few times just uses too much VRAM before it clears, hence crashes. But if you seek around without clicking play more than a few times it shouldnt give you troubles. Clicking F5/Preview after a fair while also gives troubles, though these are vs-edit issues to do with queue caches or something.
PRAGMA
25th January 2022, 22:04
Update: v1.6.4 fixes a memory leak that happens because I have no fucking idea, but alas, if anyone had any VRAM issues please try on v1.6.4.
Some other changes are there as well, mainly changes to how half=True param works. Spoiler: It doesnt exist, but dont worry see changelog.
Selur
26th January 2022, 16:54
v1.6.4 works again for me :) Thanks!
mastrboy
14th February 2022, 23:51
v1.6.4 works again for me :) Thanks!
I get insta crashes on 1.6.4, 1.6.0-1.6.3 works for some frames before it crash...
The only "stable" version for me seems to be 1.5.0.
Testing with model:RealESRGAN_x2plus.pth
Is there any debug logs I can activate to figure out the issue?
Hardware:
Nvidia RTX3090 (tried both 4xx and 5xx series drivers)
AMD 3900x
32GB Ram
Selur
15th February 2022, 08:14
What does your script look like?
What resolution is your input?
You might simply be running out of VRAM.
mastrboy
15th February 2022, 11:40
What does your script look like?
What resolution is your input?
You might simply be running out of VRAM.
Source resolution I'm testing on is 720x540, script:
chroma = video.resize.Spline36(video.width*2,video.height*2)
video = video.fmtc.resample (css="444")
video = video.fmtc.matrix (mat="709", col_fam=vs.RGB)
vsgan = VSGAN(video, device="cuda")
vsgan.load_model(r"RealESRGAN_x2plus.pth")
vsgan.run()
video = vsgan.clip
video = video.fmtc.matrix (mat="709", col_fam=vs.YUV, bits=16)
video = video.fmtc.resample (css="420")
video = video.fmtc.bitdepth (bits=8)
video= core.std.Merge(clipa=video, clipb=chroma, weight=[0, 1])
video.set_output()
It runs fine with 1.5.0, during an encode HWinfo64 reports ~3,5-4GB VRAM allocated
Selur
15th February 2022, 12:02
Yeah, that will not work with current VSGAN as the syntax changed.
Instead of:
vsgan = VSGAN(video, device="cuda")
vsgan.load_model(r"RealESRGAN_x2plus.pth")
vsgan.run()
video = vsgan.clip
you would call:
vsgan = ESRGAN(clip=video ,device="cuda")
vsgan.load(r"RealESRGAN_x2plus.pth") # load() instead of load_model()
vsgan.apply() # <- not run()
video = vsgan.clip
see: https://vsgan.phoeniix.dev/en/stable/getting-started.html and the changelog of v1.6.0
Cu Selur
mastrboy
19th February 2022, 14:28
Yeah, that will not work with current VSGAN as the syntax changed.
see: https://vsgan.phoeniix.dev/en/stable/getting-started.html and the changelog of v1.6.0
Cu Selur
Thanks for the help, I'll give it another try with the new syntax.
mastrboy
21st April 2022, 18:08
Is it normal for Linux to be almost 2x faster than Windows when using the exact same vapoursynth script with VSGAN?
Windows: 3.98fps
Linux: 7.67fps
Or did I do something wrong with the enviroment setup for pytorch/vapoursynth/vsgan?
ReinerSchweinlin
22nd April 2022, 11:10
A speed difference of this magnitude is a sign of different configurations... Maybe, if you are running NVIDIA Cards, setting the card to compute mode in windows will help?
knumag
22nd April 2022, 15:59
Hi.
Im using a 1060 6GB and only getting around 0.2 fps with "2x_VHS-upscale-and-denoise_Film_477000_G.pth" from https://upscale.wiki/wiki/Model_Database
Also getting this warning in cmd "vsgan\utilities.py:36: UserWarning: The given buffer is not writable, and PyTorch does not support non-writable tensors. This means you can write to the underlying (supposedly non-writable) buffer using the tensor. You may want to copy the buffer to protect its data or make it writable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\torch\csrc\utils\tensor_new.cpp:998.)
torch.frombuffer("
Is that speed correct with 1060 6GB?
When looking at task manager the gpu jumps to 20% every 2-3 seconds, but idle between.
See that my dedicated memory is almost full. Is that the reason for it being that slow?
Do i need another card with more vram?
I have a threadripper 1950x, but no way to use that instead of GPU?
With "RealESRGAN_x2plus.pth" I'm getting 0.5 fps
mastrboy
22nd April 2022, 17:38
A speed difference of this magnitude is a sign of different configurations... Maybe, if you are running NVIDIA Cards, setting the card to compute mode in windows will help?
It's an Nvidia RTX 3090, I can't find that option in the control panel, is it only available on Quadro cards?
I can see a compute mode with the CLI though, it's currently configured to Default:
nvidia-smi -q | Select-String -Pattern "compute"
Compute Mode : Default
Selur
22nd April 2022, 17:49
What does the script look like? What is the resolution of the source?
knumag
22nd April 2022, 17:55
Pal SD from vhs after qtgmc.
But should be something wrong somewhere, I'm just getting black video as ouput... :D
import vapoursynth as vs
core = vs.core
core.num_threads = 8
core.max_cache_size = 6000
video = core.lsmas.LWLibavSource(source=r"1.mp4")
from vsgan import ESRGAN
video = core.fmtc.resample (clip=video, css="444")
video = core.fmtc.matrix (clip=video, mat="709", col_fam=vs.RGB)
vsgan = ESRGAN(clip=video ,device="cuda")
vsgan.load(r"RealESRGAN_x2plus.pth")
vsgan.apply()
video = vsgan.clip
video = core.fmtc.matrix (clip=video, mat="709", col_fam=vs.YUV, bits=16)
video = core.fmtc.resample (clip=video, css="420")
video = core.fmtc.bitdepth (clip=video, bits=8)
video = core.resize.Spline36(video, 1440, 1080)
video.set_output()
Changed to this and it's working
import vapoursynth as vs
core = vs.core
core.num_threads = 8
core.max_cache_size = 6000
video = core.lsmas.LWLibavSource(source=r"1.mp4")
from vsgan import ESRGAN
video = core.resize.Bicubic(clip=video, format=vs.RGB24, matrix_in_s="709", range_s="limited")
vsgan = ESRGAN(clip=video ,device="cuda")
vsgan.load(r"RealESRGAN_x2plus.pth")
vsgan.apply()
video = vsgan.clip
video = core.fmtc.matrix (clip=video, mat="709", col_fam=vs.YUV, bits=16)
video = core.fmtc.resample (clip=video, css="420")
video = core.fmtc.bitdepth (clip=video, bits=8)
video = core.resize.Spline36(video, 1440, 1080)
video.set_output()
Selur
22nd April 2022, 19:36
Script seems fine to me.
(as a side note: using https://github.com/HolyWu/vs-realesrgan/tree/master/vsrealesrgan is nearly 2 times faster than vsgan with RealESRGAN here.)
Do you use the same driver version on Linux and Windows?
knumag
25th April 2022, 13:16
Script seems fine to me.
(as a side note: using https://github.com/HolyWu/vs-realesrgan/tree/master/vsrealesrgan is nearly 2 times faster than vsgan with RealESRGAN here.)
Do you use the same driver version on Linux and Windows?
Having problems installing vsrealesrgan.
Followed your guide here: https://forum.selur.net/thread-1858.html
But when installing vsdpir and vsrealesrgan, Im getting errors.
Using cached VapourSynth-58.zip (558 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [15 lines of output]
Traceback (most recent call last):
File "C:\Users\knumag\AppData\Local\Temp\pip-install-2415kpn4\vapoursynth_712c69d39f4a4718a3f6b523a85b39eb\setup.py", line 64, in <module>
dll_path = query(winreg.HKEY_LOCAL_MACHINE, REGISTRY_PATH, REGISTRY_KEY)
File "C:\Users\knumag\AppData\Local\Temp\pip-install-2415kpn4\vapoursynth_712c69d39f4a4718a3f6b523a85b39eb\setup.py", line 38, in query
reg_key = winreg.OpenKey(hkey, path, 0, winreg.KEY_READ)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:\Users\knumag\AppData\Local\Temp\pip-install-2415kpn4\vapoursynth_712c69d39f4a4718a3f6b523a85b39eb\setup.py", line 67, in <module>
raise OSError("Couldn't detect vapoursynth installation path")
OSError: Couldn't detect vapoursynth installation path
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
Any suggestions?
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.