Log in

View Full Version : FineSharp for VapourSynth


Pages : [1] 2

Chikuzen
20th November 2012, 09:06
I ported Didée's FineSharp (http://forum.doom9.org/showthread.php?p=1569035#post1569035) script to VapourSynth.

https://gist.github.com/chikuzen/6103665

requirement:
VapourSynth r19 or later
RemoveGrain.dll
Repair.dll

usage:
at first, download (or copy/paste to your texteditor) and put it to python3.3/Lib/site-packages as 'finesharp.py'.

import vapoursynth as vs
import finesharp
core = vs.get_core()
core.avs.LoadPlugin('/path/to/RemoveGrain.dll')
core.avs.LoadPlugin('/path/to/Repair.dll')
clip = something
fs = finesharp.FineSharp()
clip = fs.sharpen(clip, other options...)


new version:

finesharp 2016.08.21 (https://gist.github.com/4re/8676fd350d4b5b223ab9), updated for Vapoursynth R33, ~10% faster for 8bit input, no difference for 16bit. Note it requires Vapoursynth R33 or more recent.

Myrsloik
28th July 2013, 19:36
return self.std.Lut2([c1, c2], lut, planes)
should be
return self.std.Lut2([c1, c2], planes=planes, lut=lut)
Your patch to add function evaluation to lut changed the order of the arguments so use named arguments instead.

buchanan
28th July 2013, 21:24
Chikuzen,

I applied the modifications you described here (http://forum.doom9.org/showthread.php?p=1638579#post1638579) and got the filter working with VS R19 RC2, however here is the result:

Input :
http://img4.hostingpics.net/thumbs/mini_721889input.jpg (http://www.hostingpics.net/viewer.php?id=721889input.jpg)

Output ( vid=fs.sharpen(vid,sstr=0.7) )
http://img4.hostingpics.net/thumbs/mini_511132output.jpg (http://www.hostingpics.net/viewer.php?id=511132output.jpg)

Chikuzen
29th July 2013, 12:25
updated first post link and example.

https://dl.dropboxusercontent.com/u/19797864/forum/finesharp_test.jpg

buchanan
22nd October 2013, 17:59
Hello !

Using FineSharp with this r21 test version of Vapoursynth (http://forum.doom9.org/showthread.php?p=1649306#post1649306) produces this strange result :

Input
http://img15.hostingpics.net/thumbs/mini_154233input.jpg (http://www.hostingpics.net/viewer.php?id=154233input.jpg)

Output
http://img15.hostingpics.net/thumbs/mini_495660output.jpg (http://www.hostingpics.net/viewer.php?id=495660output.jpg)

Myrsloik
22nd October 2013, 19:15
Hello !

Using FineSharp with this r21 test version of Vapoursynth (http://forum.doom9.org/showthread.php?p=1649306#post1649306) produces this strange result :

Input
http://img15.hostingpics.net/thumbs/mini_154233input.jpg (http://www.hostingpics.net/viewer.php?id=154233input.jpg)

Output
http://img15.hostingpics.net/thumbs/mini_495660output.jpg (http://www.hostingpics.net/viewer.php?id=495660output.jpg)

I made a typo in the asm. I'll put up a fixed version tomorrow.

sl1pkn07
22nd October 2013, 19:34
this plugin work with the internal vsremovegrain?

greetings

Are_
22nd October 2013, 19:50
If you fix the syntax, sure thing it will. It only uses the blur modes from removegrain, the ones that are implemented in vapoursynth version.

Myrsloik
22nd October 2013, 19:57
If you fix the syntax, sure thing it will. It only uses the blur modes from removegrain, the ones that are implemented in vapoursynth version.

Whoever does those changes should change it to use gray format for the masks at the same time. No reason to waste memory on that.

Are_
16th December 2014, 14:45
I updated it to make use of native filters only, to use gray format for all the filtering, and also ditched the class, so it should be easier to use.
Now it also supports 8, 9, 10 and 16 bits.

finesharp 2014-12-17 (https://gist.github.com/4re/8676fd350d4b5b223ab9)

requirement:
VapourSynth r23 or later

Usage:
Download (or copy/paste to your texteditor) and put it in python3.4/Lib/site-packages as 'finesharp.py'.

import vapoursynth as vs
import finesharp
core = vs.get_core()
...
clip = something
clip = finesharp.sharpen(clip, other options...)

Myrsloik
16th December 2014, 14:49
I updated it to make use of native filters only, to use gray format for all the filtering, and also ditched the class, so it should be easier to use.

finesharp 2014-12-16 (https://gist.github.com/4re/8676fd350d4b5b223ab9)

requirement:
VapourSynth r23 or later

...

If I'm not mistaken it will work when the input clip has up to 10 bit precision. If you conditionally replace Lut2 with Expr when the input clip > 10 bits you can easily make it work for 16 bit clips too.

Are_
16th December 2014, 14:52
Unfortunately it does not, because I'm not smart enough to fix the code for that.

feisty2
16th December 2014, 15:14
it's not that hard actually,
maybe take the original avs (http://forum.doom9.org/showthread.php?p=1569035#post1569035) script as reference would be much easier
it's almost a copy paste styleee work
sstr = string (sstr) ----- sstr = repr (sstr)
mt_lutxy (c,b,xxxxxxxx) ---- core.std.Expr ([c,b],["xxxxxxx"])
and to make the 8bpc expr work at 16bpc
x ----- x 256 /
y ----- y 256 /
z ----- z 256 /
and add 256 * at the end of the expr

buchanan
16th December 2014, 20:30
If I'm not mistaken it will work when the input clip has up to 10 bit precision. If you conditionally replace Lut2 with Expr when the input clip > 10 bits you can easily make it work for 16 bit clips too.

Just tried with a 10bit clip, it still throws an error "Clip must be 8bit YUV" ;)

Are_
16th December 2014, 21:45
If I'm not mistaken it will work when the input clip has up to 10 bit precision. If you conditionally replace Lut2 with Expr when the input clip > 10 bits you can easily make it work for 16 bit clips too.

Just tried with a 10bit clip, it still throws an error "Clip must be 8bit YUV" ;)

Yeah it works, but it adds like 20/30 of startup, I didn't permit it for that reason, but I suppose I can change that check.

I tried what you said Myrsloik, but the output was not the same, more grainy, I guess my expresion sucked and I gave up. I will keep at it another day.

Thanx for the tips feisty2, when I have a chance I will try to make it work that way. Btw, you don't need to convert anything to strings in python, that's an avisynth limitation when dealing with strings. In python you do something like:
'x y %r - +' % (thr)
with positional arguments or
'x y {thr} - +'.format(thr=thr)
with named arguments.

TheFluff
16th December 2014, 22:24
.format() is the preferred way to do string formatting in Python 3, the % notation is a Python 2 backwards compatibility thing. You can use .format() with positional arguments too, just use empty brackets:
'x y {} - +'.format(thr)

Are_
17th December 2014, 18:43
Updated to support 8, 9, 10 and 16 bits.

Is it normal for expr to not run multithreaded? Or it looks like it:
No filtering: ~1700 fps, all cores about 50%
finesharp lut: ~400 fps, all cores about 50%
finesharp expr: ~50 fps, one core maxed out, all the other cores almost dormant

Myrsloik
17th December 2014, 23:25
Updated to support 8, 9, 10 and 16 bits.

Is it normal for expr to not run multithreaded? Or it looks like it:
No filtering: ~1700 fps, all cores about 50%
finesharp lut: ~400 fps, all cores about 50%
finesharp expr: ~50 fps, one core maxed out, all the other cores almost dormant

Expr can only run on one core at a time and it's fairly slow. All the other functions are most likely a lot faster so it ends up bottlenecking everything.

One day I'm going to use runtime code generation. It's the only way to get good speeds out of this kind of filter...

stax76
6th September 2015, 10:57
has anybody updates the script?

diff = self.Lut2([clip, c2], function=expr, planes=0)

Python exception: Lut2: argument clipa is not of array type but more than one value was supplied
Traceback (most recent call last):
File "vapoursynth.pyx", line 1467, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:24719)
File "D:\Temp\Encoding\test temp files\test.vpy", line 7, in <module>
clip = finesharp.FineSharp().sharpen(clip = clip)
File "D:\Projekte\GitHub\staxrip\bin\Apps\Plugins\vs\finesharp\finesharp.py", line 148, in sharpen
diff = self.Lut2([clip, c2], function=expr, planes=0)
File "vapoursynth.pyx", line 1366, in vapoursynth.Function.__call__ (src\cython\vapoursynth.c:23214)
vapoursynth.Error: Lut2: argument clipa is not of array type but more than one value was supplied

Are_
6th September 2015, 11:36
Yes, in this very same page (http://forum.doom9.org/showthread.php?p=1702894#post1702894)

stax76
6th September 2015, 11:58
sorry I missed it :thanks:

tObber166
26th January 2016, 20:46
import vapoursynth as vs
import finesharp
core = vs.get_core()
clip = core.lsmas.LWLibavSource(source = r'c:\test4.mts')
clip = finesharp.sharpen(clip)
clip.set_output()


"AttributeError: module 'finesharp' has no attribute 'sharpen"


What am I missing here?

sl1pkn07
26th January 2016, 20:50
import finesharp as finesharp

tObber166
26th January 2016, 21:12
Nope, I've tried that, same error output.

I'm using portable version x64, with finesharp.py in root folder, if thats matter?



EDIT: Never mind, it's working now

foxyshadis
29th January 2016, 12:21
import finesharp as finesharp

For future reference, this line would be:

from finesharp import finesharp

Then you can use finesharp.sharpen(). Otherwise you're stuck with finesharp.finesharp.sharpen(), and nobody likes that.

Selur
21st February 2016, 11:36
put it to python3.3/Lib/site-packages as 'finesharp.py'.
Is there a way to load the script from a custom path? (for example "G:\Hybrid\Vapoursynth\scripts\finesharp.py"?

Is
core.avs.LoadPlugin('/path/to/RemoveGrain.dll')
core.avs.LoadPlugin('/path/to/Repair.dll')
still necessary or could RemoveGrainVS be used instead?

sl1pkn07
21st February 2016, 11:42
try with https://gist.github.com/4re/8676fd350d4b5b223ab9

Selur
21st February 2016, 11:58
# Imports
import vapoursynth as vs
import os
import sys
core = vs.get_core()
# Include Scripts
scriptPath='G:/Hybrid/Vapoursynth/scripts'
sys.path.append(os.path.abspath(scriptPath))
# Import finesharp.py
import finesharp as finesharp
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/Vapoursynth/vapoursynth64/plugins/SourceFilter/FFMS2/ffms2.dll")
# Loading Source: F:/TestClips&Co/Test-AC3-5.1.avi
clip = core.ffms2.Source(source="F:/TESTCL~1/TEST-A~1.AVI",cachefile="H:/Temp/avi_54a4199c1a3d3b1476ea1d15dc267332_491.ffindex",fpsnum=25)
# Sharpen
clip = finesharp.sharpen(clip)
# Output
clip.set_output()
gives me:
Failed to evaluate the script:
Python exception: module 'finesharp' has no attribute 'sharpen'
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1489, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:26885)
File "H:/Temp/tempPreviewVapoursynthFile11_07_39_848.vpy", line 16, in <module>
# Output
AttributeError: module 'finesharp' has no attribute 'sharpen'

Are_
21st February 2016, 12:10
There is a super-easy way to load from a custom place. In your site-packages folder create a file with ".pth" extension, in linux it will be something like for example:
/usr/lib/python3.5/site-packages/vapoursynth_modules.pth
Now inside that file put the custom path where the .py modules will be placed, you can add many, just one per line.

About your error I think you are using the original script from this thread, not the one sl1pkn07 linked to you. The original is somewhat dated, it does not use vapoursynth native plugins and supports only 8bit.

Selur
21st February 2016, 12:15
finesharp.py script I use is:
# finesharp.py - finesharp module for VapourSynth
# Original author: Didee (http://forum.doom9.org/showthread.php?t=166082)
# Requirement: VapourSynth r25 or later
# Rev: 2016-01-09

import vapoursynth as vs


def spline(x, coordinates):
def get_matrix(px, py, l):
matrix = []
matrix.append([(i == 0) * 1.0 for i in range(l + 1)])
for i in range(1, l - 1):
p = [0 for t in range(l + 1)]
p[i - 1] = px[i] - px[i - 1]
p[i] = 2 * (px[i + 1] - px[i - 1])
p[i + 1] = px[i + 1] - px[i]
p[l] = 6 * (((py[i + 1] - py[i]) / p[i + 1]) - (py[i] - py[i - 1]) / p[i - 1])
matrix.append(p)
matrix.append([(i == l - 1) * 1.0 for i in range(l + 1)])
return matrix

def equation(matrix, dim):
for i in range(dim):
num = matrix[i][i]
for j in range(dim + 1):
matrix[i][j] /= num
for j in range(dim):
if i != j:
a = matrix[j][i]
for k in range(i, dim + 1):
matrix[j][k] -= a * matrix[i][k]

if not isinstance(coordinates, dict):
raise TypeError('coordinates must be a dict')

length = len(coordinates)
if length < 3:
raise ValueError('coordinates require at least three pairs')

px = [key for key in coordinates.keys()]
py = [val for val in coordinates.values()]
matrix = get_matrix(px, py, length)
equation(matrix, length)
for i in range(length + 1):
if x >= px[i] and x <= px[i + 1]:
break
j = i + 1
h = px[j] - px[i]
s = matrix[j][length] * (x - px[i]) ** 3
s -= matrix[i][length] * (x - px[j]) ** 3
s /= 6 * h
s += (py[j] / h - h * matrix[j][length] / 6) * (x - px[i])
s -= (py[i] / h - h * matrix[i][length] / 6) * (x - px[j])
return s


def clamp(x, maximum):
return max(0, min(round(x), maximum))


def sharpen(clip, mode=1, sstr=2.0, cstr=None, xstr=0.19, lstr=1.49, pstr=1.272, ldmp=None):
"""Small and relatively fast realtime-sharpening function, for 1080p,
or after scaling 720p -> 1080p during playback
(to make 720p look more like being 1080p)
It's a generic sharpener. Only for good quality sources!
(If the source is crap, FineSharp will happily sharpen the crap.) ;)
Noise/grain will be enhanced, too. The method is GENERIC.

Modus operandi: A basic nonlinear sharpening method is performed,
then the *blurred* sharp-difference gets subtracted again.

Args:
clip (clip): vs.YUV or vs.GRAY video.
mode (int): 1 to 3, weakest to strongest. When negative -1 to -3,
a broader kernel for equalisation is used.
sstr (float): strength of sharpening, 0.0 up to ??
cstr (float): strength of equalisation, 0.0 to ? 2.0 ?
(recomm. 0.5 to 1.25, default AUTO)
xstr (float): strength of XSharpen-style final sharpening, 0.0 to 1.0
(but, better don't go beyond 0.249 ...)
lstr (float): modifier for non-linear sharpening
pstr (float): exponent for non-linear sharpening
ldmp (float): "low damp", to not overenhance very small differences
(noise coming out of flat areas, default sstr+1)

Example:

.. code-block:: python

...
import finesharp
...
clip = finesharp.sharpen(clip)
...
"""
core = vs.get_core()

bd = clip.format.bits_per_sample
max_ = 2 ** bd - 1
mid = (max_ + 1) // 2
scl = (max_ + 1) // 256
x = 'x {} /'.format(scl)
y = 'y {} /'.format(scl)

src = clip

if src.format.color_family != vs.YUV and src.format.color_family != vs.GRAY:
raise ValueError('clip must be YUV or GRAY color family.')

if bd < 8 or bd > 16:
raise ValueError('clip must be 8..16 bits.')

mode = int(mode)
if abs(mode) > 3 or mode == 0:
raise ValueError('mode must be 1, 2, 3, -1, -2 or -3.')

sstr = float(sstr)
if sstr < 0.0:
raise ValueError('sstr must be larger than zero.')

if src.format.color_family != vs.GRAY:
clip = core.std.ShufflePlanes(clips=clip, planes=0, colorfamily=vs.GRAY)

if cstr is None:
cstr = spline(sstr, {0: 0, 0.5: 0.1, 1: 0.6, 2: 0.9, 2.5: 1, 3: 1.09,
3.5: 1.15, 4: 1.19, 8: 1.249, 255: 1.5})
if mode > 0:
cstr **= 0.8
cstr = float(cstr)

xstr = float(xstr)
if xstr < 0.0:
raise ValueError('xstr must be larger than zero.')

lstr = float(lstr)

pstr = float(pstr)

if ldmp is None:
ldmp = sstr + 0.1
ldmp = float(ldmp)

rg = 20 - (mode > 0) * 9

if sstr < 0.01 and cstr < 0.01 and xstr < 0.01:
return src

if abs(mode) == 1:
c2 = core.rgvs.RemoveGrain(clip=clip, mode=[11]).rgvs.RemoveGrain(mode=[4])
else:
c2 = core.rgvs.RemoveGrain(clip=clip, mode=[4]).rgvs.RemoveGrain(mode=[11])
if abs(mode) == 3:
c2 = core.rgvs.RemoveGrain(clip=c2, mode=[4])

if bd in [8, 9, 10]:
def expr(x, y):
d = x - y
absd = abs(d)
e0 = ((absd / lstr) ** (1 / pstr)) * sstr
e1 = d / (absd + 0.001)
e2 = (d * d) / (d * d + ldmp)
return clamp(e0 * e1 * e2 + mid, max_)

diff = core.std.Lut2(clipa=clip, clipb=c2, function=expr)
else:
expr = '{x} {y} - abs {lstr} / log 1 {pstr} / * exp ' \
'{sstr} * {x} {y} - {x} {y} - abs 0.001 + / * {x} {y} - log 2 * exp ' \
'{x} {y} - log 2 * exp {ldmp} + / * 128 + {scl} *'
expr = expr.format(x=x, y=y, lstr=lstr, pstr=pstr, sstr=sstr, ldmp=ldmp, scl=scl)
diff = core.std.Expr(clips=[clip, c2], expr=expr)

shrp = clip
if sstr >= 0.01:
shrp = core.std.MergeDiff(clipa=shrp, clipb=diff)

if cstr >= 0.01:
if bd in [8, 9, 10]:
def expr(x):
return clamp((x - mid) * cstr + mid, max_)
diff = core.std.Lut(clip=diff, function=expr)
else:
expr = 'x {mid} - {cstr} * {mid} +'.format(mid=mid, cstr=cstr)
diff = core.std.Expr(clips=diff, expr=expr)
diff = core.rgvs.RemoveGrain(clip=diff, mode=[rg])
shrp = core.std.MakeDiff(clipa=shrp, clipb=diff)

if xstr >= 0.01:
if bd in [8, 9]:
def expr(x, y):
return clamp(x + (x - y) * 9.9, max_)
xyshrp = core.std.Lut2(clipa=shrp, clipb=core.rgvs.RemoveGrain(clip=shrp, mode=[20]), function=expr)
else:
expr = 'x x y - 9.9 * +'
xyshrp = core.std.Expr(clips=[shrp, core.rgvs.RemoveGrain(clip=shrp, mode=[20])], expr=expr)
rpshrp = core.rgvs.Repair(clip=xyshrp, repairclip=shrp, mode=[12])
shrp = core.std.Merge(clipa=rpshrp, clipb=shrp, weight=[1 - xstr])

if src.format.color_family != vs.GRAY:
shrp = core.std.ShufflePlanes(clips=[shrp, src], planes=[0, 1, 2], colorfamily=src.format.color_family)

return shrp
and it's location on my system is ''G:/Hybrid/Vapoursynth/scripts/finesharp.py"

-> WORKS NOW!! Had to restart VapourSynth Editor,...

Mystery Keeper
22nd February 2016, 00:28
Yes, Python quirk. It caches (compiles?) the saved scripts, so editing them while Python is running does nothing until you close whatever process used Python.

hydra3333
18th June 2016, 16:51
thank you.
Now of to find the latest versions of these
RemoveGrain.dll
Repair.dll

beginner query -
I assume they could go into the root folder of embedded python where VS was also extracted to ? or a "DLLs" subfolder to be safer.

Reel.Deel
18th June 2016, 19:36
thank you.
Now of to fund the latest versions of these
RemoveGrain.dll
Repair.dll

beginner query -
I assume they could go into the root folver of embessed python where VS was also extracted to ? or a "DLLs" subfolder to be safer.

Read the documentation: http://www.vapoursynth.com/doc/autoloading.html

Also RemoveGrain and Repair already come included with VapourSynth. If you're looking for anything else take a look at this list here: http://www.vapoursynth.com/doc/pluginlist.html

hydra3333
19th June 2016, 04:19
OK. Thank you.

Also RemoveGrain and Repair already come included with VapourSynth
Ah, good oh.

hydra3333
21st August 2016, 02:32
So, which of these lines is the "right" way ?

import finesharp
import finesharp as finesharp
from finesharp import finesharp

to then use
clip = finesharp.sharpen(clip)

hydra3333
21st August 2016, 03:29
Downloaded the latest finesharp from post #1, but I must be doing something wrong, to receive the error message, but can't see what ... suggestions welcomed.
T:\HDTV\WDTVlive\MP4-VS\1>"C:\SOFTWARE\Vapoursynth\VSPipe.exe" "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.21.11.50.29.84.vpy" - --y4m | "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\x264-mp4.exe" - --stdin y4m --thread-input --frames 45810 --profile high --level 4.1 --preset slow --interlaced --tff --no-cabac --crf 16 --sar 64:45 --colormatrix bt470bg -o "s:\HDTV\WDTVlive\MP4-VS\1\test-temp.2016.08.21.11.50.29.84.h264"
Script evaluation failed:
Python exception: There is no function named RemoveGrain
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1491, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:26897)
File "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.21.11.50.29.84.vpy", line 458, in <module>
main()
File "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.21.11.50.29.84.vpy", line 151, in main
video = fs.FineSharp().sharpen(video)
File "C:\SOFTWARE\Vapoursynth\finesharp.py", line 71, in __init__
self.rgrain = self.core.avs.RemoveGrain
File "src\cython\vapoursynth.pyx", line 1264, in vapoursynth.Plugin.__getattr__ (src\cython\vapoursynth.c:23480)
AttributeError: There is no function named RemoveGrain




import vapoursynth as vs
import havsfuncTS as haf # this version uses vanilla TemporalSoften instead of TemporalSoften2, as it will be "better" over time
import mvsfunc as mvs # http://forum.doom9.org/showthread.php?t=172564
import finesharp as fs # http://forum.doom9.org/showthread.php?p=1755227#post1755227 http://avisynth.nl/index.php/FineSharp
core = vs.get_core(accept_lowercase=True) # leave off threads=8 so it auto-detects threads
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\AddGrain.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\d2vsource.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\Deblock.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\DFTTest.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\fmtconv.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\KNLMeansCL.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\libawarpsharp2.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\libmvtools.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\libnnedi3.dll') # the r'' indicates do not treat special characters and accept backslashes
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\scenechange.dll') # http://forum.doom9.org/showthread.php?t=166769
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\vsdctfilter.dll') # http://vfrmaniac.fushizen.eu/works
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\vsfft3dfilter.dll') # http://vfrmaniac.fushizen.eu/works
core.std.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\vapoursynth32\plugins\dll-to-choose-from\Yadifmod.dll') # the r'' indicates do not treat special characters and accept backslashes
core.avs.LoadPlugin(r'C:\SOFTWARE\Vapoursynth\DGIndex\DGDecodeNV.dll')
core.avs.LoadPlugin(r'C:\SOFTWARE\DGindex\DGDecode.dll')
def main():
video = core.avs.MPEG2Source(r'T:\HDTV\WDTVlive\MP4-VS\1\test.d2v',info=0,iPP=True,cpu=6) # DEBLOCK and DERING
video = core.std.SeparateFields(video, tff=True)
video = haf.Deblock_QED(video)
video = haf.Weave(video, tff=True)
video = mvs.AssumeTFF(video)
video = haf.QTGMC(video, TFF=True, Preset="Very Slow", Sharpness=1.2, SLMode=2, EZKeepGrain=1.2, NoiseProcess=2) # result is double framerate progressive, so re-interlate it later
video = fs.FineSharp().sharpen(video)
video = core.std.SeparateFields(video, tff=True)
video = core.std.SelectEvery(video, cycle=4, offsets=[0, 3]) # looks like avisynth
video = haf.Weave(video, tff=True)
video = mvs.AssumeTFF(video)
video.set_output()
return True
#----------------------------------------------------------------------------------------------------
#if __name__ == "__main__":
# # execute main only if run as a script
# main()
main()

hydra3333
21st August 2016, 03:47
If I edit finesharp.py like this

#self.rgrain = self.core.avs.RemoveGrain
self.rgrain = self.core.rgvs.RemoveGrain
#self.repair = self.core.avs.Repair
self.repair = self.core.rgvs.Repair
I receive
T:\HDTV\WDTVlive\MP4-VS\1>"C:\SOFTWARE\Vapoursynth\VSPipe.exe" "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.21.12.13.34.49.vpy" - --y4m | "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\x264-mp4.exe" - --stdin y4m --thread-input --frames 45810 --profile high --level 4.1 --preset slow --interlaced --tff --no-cabac --crf 16 --sar 64:45 --colormatrix bt470bg -o "s:\HDTV\WDTVlive\MP4-VS\1\test-temp.2016.08.21.12.13.34.49.h264"
Script evaluation failed:
Python exception: RemoveGrain: Too many unnamed arguments specified
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1491, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:26897)
File "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.21.12.13.34.49.vpy", line 458, in <module>
main()
File "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.21.12.13.34.49.vpy", line 151, in main
video = fs.FineSharp().sharpen(video)
File "C:\SOFTWARE\Vapoursynth\finesharpmod20160821.py", line 136, in sharpen
c2 = self.rgrain(self.rgrain(clip, 11, -1), 4, -1)
File "src\cython\vapoursynth.pyx", line 1353, in vapoursynth.Function.__call__ (src\cython\vapoursynth.c:24744)
vapoursynth.Error: RemoveGrain: Too many unnamed arguments specified

So I'm a bit stuck.

hydra3333
21st August 2016, 04:02
Tried Selur's version from http://forum.doom9.org/showthread.php?p=1757955#post1757955 which looks different and is called differently, and it doesn't crash (don't know how functionally equivalent it is).

import finesharpmod20160821 as finesharp
...
video = finesharp.sharpen(video)

~SimpleX~
21st August 2016, 10:21
This script needs an upgrade, it uses avisynth functions instead of VS equivalents. Why do you even need finesharp? It's designed for realtime sharpening of upscaled (720 -> 1080) videos. Not quite suitable for video processing.

feisty2
21st August 2016, 10:27
This script needs an upgrade, it uses avisynth functions instead of VS equivalents. Why do you even need finesharp? It's designed for realtime sharpening of upscaled (720 -> 1080) videos. Not quite suitable for video processing.

because there's no other choice..?

Selur
21st August 2016, 10:34
I thing the point is that https://gist.github.com/4re/8676fd350d4b5b223ab9 works and https://gist.github.com/chikuzen/6103665 doesn't ;)
Whether another sharpener (minsharp, AWarpSharp2) might be better suited for whatever sharpening hydra3333 wants to perform shouldn't really matter,..

Are_
21st August 2016, 13:05
finesharp 2016.08.21 (https://gist.github.com/4re/8676fd350d4b5b223ab9), updated for Vapoursynth R33, ~10% faster for 8bit input, no difference for 16bit.

Selur
21st August 2016, 13:11
Thanks. :)

hydra3333
21st August 2016, 16:54
Thank you.
This script needs an upgrade, it uses avisynth functions instead of VS equivalents. Why do you even need finesharp? It's designed for realtime sharpening of upscaled (720 -> 1080) videos. Not quite suitable for video processing.

Was just comparing it to LSFmod's output, however with the default settings it appears to be a tad brutal for my needs. Oh well. I see some posts spelling is about as fine as my lazy efforts :)

hydra3333
21st August 2016, 16:58
fiensharp 2016.08.21 (https://gist.github.com/4re/8676fd350d4b5b223ab9), updated for Vapoursynth R33, ~10% faster for 8bit input, no difference for 16bit.

Thanks. R33 hasn't a formal release. Does it work with R32 ?

edit: no it doesn't.
T:\HDTV\WDTVlive\MP4-VS\1>"C:\SOFTWARE\Vapoursynth\VSPipe.exe" "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.22.01.28.50.60.vpy" - --y4m | "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\x264-mp4.exe" - --stdin y4m --thread-input --frames 45810 --profile high --level 4.1 --preset slow --interlaced --tff --no-cabac --crf 14 --sar 64:45 --colormatrix bt470bg -o "s:\HDTV\WDTVlive\MP4-VS\1\test-temp.2016.08.22.01.28.50.60.h264"
Script evaluation failed:
Python exception: VapourSynth version should be 33 or greater.
Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1491, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:26897)
File "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.22.01.28.50.60.vpy", line 469, in <module>
main()
File "T:\HDTV\WDTVlive\MP4-VS\1\test.mpg.2016.08.22.01.28.50.60.vpy", line 154, in main
video = finesharp.sharpen(video,mode=1,sstr=1.0)
File "C:\SOFTWARE\Vapoursynth\finesharp.py", line 109, in sharpen
raise EnvironmentError('VapourSynth version should be 33 or greater.')
OSError: VapourSynth version should be 33 or greater.

Are_
21st August 2016, 17:44
This version of finesharp would be too slow on vapoursynth 32

hydra3333
24th August 2016, 10:30
OK, am trying x64 VS R33 (it released today)

Selur
16th December 2017, 19:25
Haven't used finesharp for a while, but calling:
# Imports
import os
import sys
import vapoursynth as vs
core = vs.get_core()
# Import scripts folder
scriptPath = 'G:/Hybrid/vsscripts'
sys.path.append(os.path.abspath(scriptPath))
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/vsfilters/Support/fmtconv.dll")
core.avs.LoadPlugin(path="G:/Hybrid/vsfilters/SourceFilter/DGDecNV/DGDecodeNV.dll")
# Import scripts
import finesharp as finesharp
# Loading H:\to convert\test.mkv using DGSource
clip = core.avs.DGSource("H:/Temp/mkv_7ddb2a359f7f3ecc066d816f3985a1f6_14604.dgi")
# sharpening using FineSharp
clip = finesharp.sharpen(clip=clip, mode=3)

# Output
clip.set_output() (using VS R40)
I get:
Failed to evaluate the script:
Python exception: float() argument must be a string or a number, not 'vapoursynth.VideoNode'

Traceback (most recent call last):
File "src\cython\vapoursynth.pyx", line 1830, in vapoursynth.vpy_evaluateScript (src\cython\vapoursynth.c:36860)
File "H:\Temp\tempPreviewVapoursynthFile19_09_28_896.vpy", line 17, in <module>
clip = finesharp.sharpen(clip=clip, mode=3)
File "G:\Hybrid\vsscripts\finesharp.py", line 155, in sharpen
c2 = core.std.Median(clip).std.Convolution(clip, matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1])
File "src\cython\vapoursynth.pyx", line 1702, in vapoursynth.Function.__call__ (src\cython\vapoursynth.c:34634)
File "src\cython\vapoursynth.pyx", line 530, in vapoursynth.typedDictToMap (src\cython\vapoursynth.c:12921)
TypeError: float() argument must be a string or a number, not 'vapoursynth.VideoNode'
The finesharp script I use is Rev 2016-08-21.
-> tested a bit more and when I'm not using 'mode=..' it works, but using mode = 2 or mode = 3 causes the crash. Did I miss something or did this never work? :)

Cu Selur

Are_
16th December 2017, 19:51
Yeah, brainfart, try it again.

Selur
17th December 2017, 08:54
Found it, changing line 155, from
c2 = core.std.Median(clip).std.Convolution(clip, matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1])
to
c2 = core.std.Median(clip).std.Convolution(matrix=[1, 2, 1, 2, 4, 2, 1, 2, 1])
fixes the issue.
Thanks for fixing.

Cu Selur