Log in

View Full Version : BM3D (VapourSynth) versus MVTools


Pages : 1 [2] 3 4 5

tormento
5th August 2021, 20:24
I mean AVX and AVX2 intrinsics. Sorry for the confusion.
I am having AVS+ exception error when using test2 on the following script:

SetMemoryMax()
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\1_33 Grosso guaio a Chinatown\grosso.dgi",ct=132,cb=132,cl=0,cr=0)
ConvertBits(bits=32)
BM3D_cuda(sigma=0.5, radius=2)
BM3D_VAggregate(radius=2)
ConvertBits(16)
Prefetch(6)

I am using a SandyBridge with no AVX2 but it should give no error with the CUDA version. Am I doing something wrong?

Reel.Deel
5th August 2021, 20:39
I am using a SandyBridge with no AVX2 but it should give no error with the CUDA version. Am I doing something wrong?

"BM3D_CUDA" depends on "BM3D_CPU" for temporal denoising. In other words, avx2 capable processor is required.


@WolframRhodium

Since the first test version worked on the gpu only, would it be possible to add a parameter to force gpu processing only? For those that do not have avx2.

tormento
5th August 2021, 20:41
Since the first test version worked on the gpu only, would it be possible to add a parameter to force gpu processing only? For those that do not have avx2.
I think it would be easier to provide 2 versions as every script author should otherwise check if cpu supports avx2 and I don't know if there is such capability in AVS+.

kedautinh12
5th August 2021, 23:41
I am having AVS+ exception error when using test2 on the following script:

SetMemoryMax()
SetFilterMTMode("DEFAULT_MT_MODE", 2)
LoadPlugin("D:\Eseguibili\Media\DGDecNV\DGDecodeNV.dll")
DGSource("F:\In\1_33 Grosso guaio a Chinatown\grosso.dgi",ct=132,cb=132,cl=0,cr=0)
ConvertBits(bits=32)
BM3D_cuda(sigma=0.5, radius=2)
BM3D_VAggregate(radius=2)
ConvertBits(16)
Prefetch(6)

I am using a SandyBridge with no AVX2 but it should give no error with the CUDA version. Am I doing something wrong?


Of course BM3D_VAggregate() move to BM3DCPU in test2, try delete BM3D_VAggregate() and check script again

WolframRhodium
6th August 2021, 06:51
Thanks for the report. Please check the latest version (test3). I separate VAggregate from BM3D_CPU.

tormento
6th August 2021, 10:30
Of course BM3D_VAggregate() move to BM3DCPU in test2, try delete BM3D_VAggregate() and check script again
No offense, I know you try to help, but sometimes I feel your posts are just to increase post counting. :p

How can you run BM3D without aggregation? :rolleyes:

tormento
6th August 2021, 10:32
Thanks for the report. Please check the latest version (test3). I separate VAggregate from BM3D_CPU.
Thanks, I will try ASAP and report.

kedautinh12
6th August 2021, 10:53
No offense, I know you try to help, but sometimes I feel your posts are just to increase post counting. :p

How can you run BM3D without aggregation? :rolleyes:

Lol, i know i'm noob. I just try help with my ability :D:D:D

tormento
6th August 2021, 13:34
Thanks for the report. Please check the latest version (test3). I separate VAggregate from BM3D_CPU.
Tested and working. ;)

Now, I have to understand which is better between this and KNLMeansCL...

Reel.Deel
9th August 2021, 08:35
Thanks for the report. Please check the latest version (test3). I separate VAggregate from BM3D_CPU.

Thank for the update. I also confirm that it works :)

Question, are arrays allowed? I took a peek at the source code (line 429 (https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/blob/8339115ff736005b9c9f8e60e4ac8718e3a508bc/source/source_avs.cpp#L429)) and it made me think that arrays are allowed just like the VS version.
When I set sigma to [0.5, 0.0, 0.5] it sets the U plane to 255, if I use [0.5, 0.0, 0.0] it sets both U/V to 255. If I use [0.0,0.5,0.5] it sets the Y plane to 255. So I guess that using an array does work, I just don't know if setting sigma to 0 should behave that way.

WolframRhodium
9th August 2021, 11:56
Question, are arrays allowed? I took a peek at the source code (line 429 (https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/blob/8339115ff736005b9c9f8e60e4ac8718e3a508bc/source/source_avs.cpp#L429)) and it made me think that arrays are allowed just like the VS version.
When I set sigma to [0.5, 0.0, 0.5] it sets the U plane to 255, if I use [0.5, 0.0, 0.0] it sets both U/V to 255. If I use [0.0,0.5,0.5] it sets the Y plane to 255. So I guess that using an array does work, I just don't know if setting sigma to 0 should behave that way.

Yes, arrays are allowed, and the behavior is the same as the VS version. Setting gamma for a specific plane to 0 skips denoising of that plane, which gives a performance boost.

Reel.Deel
10th August 2021, 01:21
Yes, arrays are allowed, and the behavior is the same as the VS version. Setting gamma for a specific plane to 0 skips denoising of that plane, which gives a performance boost.

Thank you for the confirmation. I created a wiki page for BM3DCUDA (http://avisynth.nl/index.php/BM3DCUDA). I still need add that arrays are accepted. But if there's anything you you would like changed or added just let me know.

WolframRhodium
10th August 2021, 04:39
Thanks, nothing needs to be added.

real.finder
13th August 2021, 02:51
Yes, arrays are allowed, and the behavior is the same as the VS version. Setting gamma for a specific plane to 0 skips denoising of that plane, which gives a performance boost.

but from what I see https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/blob/8339115ff736005b9c9f8e60e4ac8718e3a508bc/cpu_source/source_avs.cpp#L461

arrays parameters don't have "+" like this https://github.com/Asd-g/AviSynthPlus-vsLGhost/blob/05d22f007ab77fe5d2634510c29d70700694d7ac/src/vsLGhost.cpp#L245

edit: seems it work with arrays as it now but it's break my avsi wrapper that like this https://github.com/realfinder/UniversalPluginsFolders/blob/master/plugins64%2B/36x/vsLGhost.avsi

WolframRhodium
13th August 2021, 03:28
but from what I see https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/blob/8339115ff736005b9c9f8e60e4ac8718e3a508bc/cpu_source/source_avs.cpp#L461

arrays parameters don't have "+" like this https://github.com/Asd-g/AviSynthPlus-vsLGhost/blob/05d22f007ab77fe5d2634510c29d70700694d7ac/src/vsLGhost.cpp#L245

edit: seems it work with arrays as it now but it's break my avsi wrapper that like this https://github.com/realfinder/UniversalPluginsFolders/blob/master/plugins64%2B/36x/vsLGhost.avsi

Does the avsi wrapper work with a "*" postfix (which indicates "zero or more" arguments of the same type)?

real.finder
13th August 2021, 09:44
Does the avsi wrapper work with a "*" postfix (which indicates "zero or more" arguments of the same type)?

it didn't https://forum.doom9.org/showpost.php?p=1914628&postcount=434 but with avs+ 3.6 I think it can with unnamed arrays, didn't test though (edit: see here https://github.com/AviSynth/AviSynthPlus/issues/226)

real.finder
15th August 2021, 19:27
after read this https://github.com/AviSynth/AviSynthPlus/issues/203 I did some workaround for BM3D case

Function BM3D_CPU(clip clip, clip "ref", float_array "sigma", int_array "block_step", int_array "bm_range", int "radius", int_array "ps_num", int_array "ps_range", bool "chroma")
{
LoadPlugin(AviSynthPlugins64PDir + "36x/BM3DCPU.dll")
BM3D_CPU(clip, ref=ref, sigma=IsArray(sigma) ? ArraySize(sigma) == 0 ? undefined : sigma : sigma, block_step=IsArray(block_step) ? ArraySize(block_step) == 0 ? undefined : block_step : block_step, bm_range=IsArray(bm_range) ? ArraySize(bm_range) == 0 ? undefined : bm_range : bm_range, radius=radius, ps_num=IsArray(ps_num) ? ArraySize(ps_num) == 0 ? undefined : ps_num : ps_num, ps_range=IsArray(ps_range) ? ArraySize(ps_range) == 0 ? undefined : ps_range : ps_range, chroma=chroma)
}


Function BM3D_CUDA(clip clip, clip "ref", float_array "sigma", int_array "block_step", int_array "bm_range", int "radius", int_array "ps_num", int_array "ps_range", bool "chroma", int "device_id", bool "fast", int "extractor_exp")
{
LoadPlugin(AviSynthPlugins64PDir + "36x/BM3DCUDA.dll")
BM3D_CUDA(clip, ref=ref, sigma=IsArray(sigma) ? ArraySize(sigma) == 0 ? undefined : sigma : sigma, block_step=IsArray(block_step) ? ArraySize(block_step) == 0 ? undefined : block_step : block_step, bm_range=IsArray(bm_range) ? ArraySize(bm_range) == 0 ? undefined : bm_range : bm_range, radius=radius, ps_num=IsArray(ps_num) ? ArraySize(ps_num) == 0 ? undefined : ps_num : ps_num, ps_range=IsArray(ps_range) ? ArraySize(ps_range) == 0 ? undefined : ps_range : ps_range, chroma=chroma, device_id, fast=fast, extractor_exp=extractor_exp)
}

anyway, arrays in avs+ still vague, I think we need pinterf explain it more, Especial why script (avsi) cases different than plugins one in case of plugins accept array even if the argument/parameter is not array type while script (avsi) is not

WolframRhodium
16th August 2021, 12:42
after read this https://github.com/AviSynth/AviSynthPlus/issues/203 I did some workaround for BM3D case
Thanks.

anyway, arrays in avs+ still vague, I think we need pinterf explain it more, Especial why script (avsi) cases different than plugins one in case of plugins accept array even if the argument/parameter is not array type while script (avsi) is not

Agree.

guest
24th August 2021, 03:22
I'm embarrassed to ask this, as I am just finding BM3D, and would like help with a basic AVS script...

kedautinh12
24th August 2021, 03:28
Read examples in here
http://avisynth.nl/index.php/BM3DCUDA
Edit: GPU ver need AVX in CPU cause BM3D_VAggregate. CPU ver need AVX2. They need strong GPU or CPU to work for speed fps

guest
24th August 2021, 03:44
Read examples in here
http://avisynth.nl/index.php/BM3DCUDA
Edit: GPU ver need AVX in CPU cause BM3D_VAggregate. CPU ver need AVX2. They need strong GPU or CPU to work for speed fps

Thanks again, I have looked there several times, but as I'm not too good at compiling scripts, unless I have a good example of one, to start with.

I need something like this :-

#Custom
LoadPlugin("%AVISYNTHPLUGINS%\mvtools\mvtools2.dll")
LoadPlugin("%AVISYNTHPLUGINS%\masktools\masktools2.dll")
LoadPlugin("%AVISYNTHPLUGINS%\RgTools\RgTools.dll")
LoadPlugin("%AVISYNTHPLUGINS%\MedianBlur2\x64\MedianBlur2.dll")
Import("%AVISYNTHPLUGINS%\scripts\extras\SMDegrain.avs")
Import("%AVISYNTHPLUGINS%\scripts\extras\Zs_RF_Shared.avs")
video=SMDegrain(video,tr=4,thSAD=400,contrasharp=true,refinemotion=true)

I have a 5950X, and a 1080 GPU....

kedautinh12
24th August 2021, 03:57
Scripts in example is very basic. If you want use BM3D in SMDegrain maybe use this script

LoadPlugin("%AVISYNTHPLUGINS%\mvtools\mvtools2.dll")
LoadPlugin("%AVISYNTHPLUGINS%\BM3D\BM3DCUDA_AVS.dll")
LoadPlugin("%AVISYNTHPLUGINS%\BM3D\BM3D_VAggregate_AVS.dll")
LoadPlugin("%AVISYNTHPLUGINS%\masktools\masktools2.dll")
LoadPlugin("%AVISYNTHPLUGINS%\RgTools\RgTools.dll")
LoadPlugin("%AVISYNTHPLUGINS%\MedianBlur2\x64\MedianBlur2.dll")
Import("%AVISYNTHPLUGINS%\scripts\extras\SMDegrain.avs")
Import("%AVISYNTHPLUGINS%\scripts\extras\Zs_RF_Shared.avs")
ffms2("...") #or any Video Sources
SMDegrain(tr=4,thSAD=400,contrasharp=true,refinemotion=true,prefilter=5)

guest
24th August 2021, 04:53
Scripts in example is very basic. If you want use in SMDegrain maybe use this script

LoadPlugin("%AVISYNTHPLUGINS%\mvtools\mvtools2.dll")
LoadPlugin("%AVISYNTHPLUGINS%\BM3D\BM3DCUDA_AVS.dll")
LoadPlugin("%AVISYNTHPLUGINS%\BM3D\BM3D_VAggregate_AVS.dll")
LoadPlugin("%AVISYNTHPLUGINS%\masktools\masktools2.dll")
LoadPlugin("%AVISYNTHPLUGINS%\RgTools\RgTools.dll")
LoadPlugin("%AVISYNTHPLUGINS%\MedianBlur2\x64\MedianBlur2.dll")
Import("%AVISYNTHPLUGINS%\scripts\extras\SMDegrain.avs")
Import("%AVISYNTHPLUGINS%\scripts\extras\Zs_RF_Shared.avs")
ffms2("...") #or any Video Sources
SMDegrain(tr=4,thSAD=400,contrasharp=true,refinemotion=true,prefilter=5)


Awesome, thankyou...

Can you clarify the:- ffms2("...") #or any Video Sources line ??

I'm trying to adapt this to RipBot264, and it uses Lsmash as the default decoder.

I'm guessing that the ("....") is the location & name of the the file to be encoded....could be left out ??

#VideoSource
LoadPlugin("D:\RipBot264v1.26.1\Tools\AviSynth plugins\ffms\2017\x64\ffms2.dll")
video=FFVideoSource("D:\Bering.Sea.Gold.mkv",cachefile="C:\Temp\RipBot264temp\job5\Bering.Sea.Gold.mkv.ffindex")

OR

#VideoSource
LoadPlugin("D:\RipBot264v1.26.1\Tools\AviSynth plugins\lsmash\LSMASHSource.dll")
video=LWLibavVideoSource("D:\Bering.Sea.Gold.mkv",cachefile="C:\Temp\RipBot264temp\job4\Bering.Sea.Gold.mkv.lwi")


Remember I'm a real noobie at this stuff, so ANY help is invaluable.

kedautinh12
24th August 2021, 05:12
Awesome, thankyou...

Can you clarify the:- ffms2("...") #or any Video Sources line ??

I'm trying to adapt this to RipBot264, and it uses Lsmash as the default decoder.

I'm guessing that the ("....") is the location & name of the the file to be encoded....could be left out ??

#VideoSource
LoadPlugin("D:\RipBot264v1.26.1\Tools\AviSynth plugins\ffms\2017\x64\ffms2.dll")
video=FFVideoSource("D:\Bering.Sea.Gold.mkv",cachefile="C:\Temp\RipBot264temp\job5\Bering.Sea.Gold.mkv.ffindex")

OR

#VideoSource
LoadPlugin("D:\RipBot264v1.26.1\Tools\AviSynth plugins\lsmash\LSMASHSource.dll")
video=LWLibavVideoSource("D:\Bering.Sea.Gold.mkv",cachefile="C:\Temp\RipBot264temp\job4\Bering.Sea.Gold.mkv.lwi")


Remember I'm a real noobie at this stuff, so ANY help is invaluable.

Yes, the ("....") is the location & name of the the file to be encoded. Use any video sources you like. If one video source have problem try change another video sources

kedautinh12
24th August 2021, 05:23
New ver ffms2
https://forum.doom9.org/showthread.php?p=1950254#post1950254
New ver L-SMASH Works
https://github.com/HomeOfAviSynthPlusEvolution/L-SMASH-Works/releases

guest
24th August 2021, 05:23
Yes, the ("....") is the location & name of the the file to be encoded. Use any video sources you like. If one video source have problem try change another video sources

Would it be possible to incorporate DGDecNV into this script ??

loadplugin("d:\don\Programming\C++\dgdecnv\DGDecodeNV\x64\Release\dgdecodenv.dll")
dgsource("Alba.dgi")

kedautinh12
24th August 2021, 05:26
Would it be possible to incorporate DGDecNV into this script ??

loadplugin("d:\don\Programming\C++\dgdecnv\DGDecodeNV\x64\Release\dgdecodenv.dll")
dgsource("Alba.dgi")

Yes, it's can

New ver DGDecNV
http://rationalqm.us/dgdecnv/binaries/

guest
24th August 2021, 05:32
Yes, it's can

New ver DGDecNV
http://rationalqm.us/dgdecnv/binaries/

Sounds interesting....

How would that affect the RipBot264 generated command

#VideoSource
LoadPlugin("D:\RipBot264v1.26.1\Tools\AviSynth plugins\lsmash\LSMASHSource.dll")
video=LWLibavVideoSource("D:\Bering.Sea.Gold.mkv",cachefile="C:\Temp\RipBot264temp\job4\Bering.Sea.Gold.mkv.lwi")

It would be great to get RipBot to use DGDecNV, instead of L Smash.

It might require DGSource to do some pre lim's.

STJAM
5th September 2021, 14:12
I am probably going to regret this inquiry but could someone post an example script for the Vapoursynth CUDA version. I have been using BM3D-r8 for quite some time and can create a working script without even the help of mvsfunc but can not seem to get this version to work. I have followed the examples on https://github.com/WolframRhodium/VapourSynth-BM3DCUDA but am still at a loss.

kedautinh12
5th September 2021, 15:07
New ver BM3D avs+
https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/actions/runs/1200055357

WolframRhodium
5th September 2021, 17:09
I am probably going to regret this inquiry but could someone post an example script for the Vapoursynth CUDA version. I have been using BM3D-r8 for quite some time and can create a working script without even the help of mvsfunc but can not seem to get this version to work. I have followed the examples on https://github.com/WolframRhodium/VapourSynth-BM3DCUDA but am still at a loss.

Sorry for the inconvenience. Could you please describe what problem occurs?

Here is a basic snippet.

yuv420ps = core.fmtc.bitdepth(yuv420p8, bits=8)

# spatial denoising
denoised_ps = core.bm3dcuda.BM3D(yuv420ps, sigma=[5, 3, 3], radius=0)

# or, temporal denoising
denoised_ps = core.bm3dcuda.BM3D(yuv420ps, sigma=[5, 3, 3], radius=1).bm3d.VAggregate(radius=1)

denoised_p8 = core.fmtc.bitdepth(denoised_ps, bits=8)

ChaosKing
5th September 2021, 17:38
Is this blockiness normal? (look at the sky)


clip = core.fmtc.bitdepth(clip, bits=32)
r=2
clip = core.bm3dcuda_rtc.BM3D(clip, sigma=[18, 16, 16], radius=r).bm3d.VAggregate(radius=r)
https://i.imgur.com/XsObV4E.png

Win10 x64, VapourSynth R55, RTX 3070TI.

STJAM
5th September 2021, 18:29
import vapoursynth as vs
import sys
core = vs.core
core.std.LoadPlugin(path=r'C:\ \VapourSynth-BM3DCUDA-r2.4\BM3DCUDA.dll')
core.std.LoadPlugin(path=r'C:\ \fmtconv-r22\win64\fmtconv.dll')
core.std.LoadPlugin(path=r'C:\ \L-SMASH-Works_20200207\plugins64\LSMASHSource.dll')
clip = core.lsmas.LWLibavSource(r'C:\Video.mkv')
clip = core.fmtc.bitdepth(clip, bits=32)
r=2
clip = core.bm3dcuda.BM3D(clip, sigma=[3, 2, 2], radius=r).bm3d.VAggregate(radius=r)

AttributeError: There is no attribute or namespace named bm3d

WolframRhodium
5th September 2021, 23:56
Is this blockiness normal? (look at the sky)


clip = core.fmtc.bitdepth(clip, bits=32)
r=2
clip = core.bm3dcuda_rtc.BM3D(clip, sigma=[18, 16, 16], radius=r).bm3d.VAggregate(radius=r)
https://i.imgur.com/XsObV4E.png

Win10 x64, VapourSynth R55, RTX 3070TI.

Blockness will be reduced with a low value of "block_step".

AttributeError: There is no attribute or namespace named bm3d

VapourSynth-BM3D also has to be loaded.

guest
6th September 2021, 04:36
New ver BM3D avs+
https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/actions/runs/1200055357

Where ???

kedautinh12
6th September 2021, 04:51
Where ???
You need github account for download that

guest
6th September 2021, 04:58
You need github account for download that

Have you got one ??

I haven't needed one yet !!!

But that page looks different to others....

kedautinh12
6th September 2021, 05:43
Here:
https://drive.google.com/file/d/1sYVmozUVrSAdd0S01AphMIa6yH8CexUW/view?usp=sharing

guest
6th September 2021, 06:54
Here:
https://drive.google.com/file/d/1sYVmozUVrSAdd0S01AphMIa6yH8CexUW/view?usp=sharing

:thanks:

tormento
6th September 2021, 12:01
Is this blockiness normal? (look at the sky)
https://github.com/WolframRhodium/VapourSynth-BM3DCUDA/issues/5

Wilbert
7th September 2021, 20:46
@kedautinh12,

I removed 85 useless 'thank you' posts of you. I ask you this only once, please stop posting useless off topic (like 'thank you' posts) stuff. Also take your time to read the forum rules, especially number 11:

11) Don't post just to increase your number of posts. If you have nothing to say on a certain matter then don't post. The number of posts on this board has no direct relation to the experience of a member.

kedautinh12
8th September 2021, 00:07
Ok, thanks. Need "thanks" button

guest
20th September 2021, 07:42
Hi WolframRhodium,

Since I started using this filter, I have been using my Ryzen 3950X & 5950X, and has worked without issue :)

However, only today, when using it on non AVX2 CPU machines, I have been getting an error that stops any encoding :(

Is there any chance that you could modify the AVS compatible builds to work with AVX CPU's ??

I'm sure I wouldn't be the only one who would appreciate it.

(unless there's some "trick" to the existing builds)

Regards

Reel.Deel
20th September 2021, 08:02
Hi WolframRhodium,

Since I started using this filter, I have been using my Ryzen 3950X & 5950X, and has worked without issue :)

However, only today, when using it on non AVX2 CPU machines, I have been getting an error that stops any encoding :(

Is there any chance that you could modify the AVS compatible builds to work with AVX CPU's ??

I'm sure I wouldn't be the only one who would appreciate it.

(unless there's some "trick" to the existing builds)

Regards

If you have a compatible GPU then you can to use BM3D_CUDA(). BM3D_CPU() at the moment is AVX2 only.

guest
20th September 2021, 09:41
If you have a compatible GPU then you can to use BM3D_CUDA(). BM3D_CPU() at the moment is AVX2 only.

I only have 2 AVX2 systems, one has an nVidia GPU, the other has an AMD :(

Hopefully "Wolf" can work his magic, as there's a LOT of AVX cpu's out there...

I know I saw that there was an AVX build, but that might have been for Vapoursynth.

What would be the next best filter ??

Reel.Deel
20th September 2021, 09:53
I know I saw that there was an AVX build, but that might have been for Vapoursynth.

Only the BM3D VAggregate function is AVX. This at least makes it usable for those that have a compatible GPU but do not have AVX2.

ChaosKing
20th September 2021, 10:03
Why not use this version then? https://github.com/HomeOfVapourSynthEvolution/VapourSynth-BM3D
Use the mvsfunc wrapper for easy usage.

guest
20th September 2021, 11:06
Only the BM3D VAggregate function is AVX. This at least makes it usable for those that have a compatible GPU but do not have AVX2.

Well, that's a shame, I only just started using BM3D, and now I can only use it on a couple of my PC's.

guest
20th September 2021, 11:07
Why not use this version then? https://github.com/HomeOfVapourSynthEvolution/VapourSynth-BM3D
Use the mvsfunc wrapper for easy usage.

I'm not able to use Vapoursynth with RipBot :(

WolframRhodium
20th September 2021, 14:55
I recommend to use VS-BM3D or to buy a GTX 750. It is hard to relax that requirement and I am busy these days.