This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Feature Request: Dynamic TensorRT models and build options
#5
Thanks for the test version. 
It looks like you've successfully implemented the dynamic TensorRT build.
I don't think there's any visual difference in the output file when using the dynamic model. It just runs a bit slower when the resolution isn't optimal, and the performance difference can vary from model to model.

I tested the SCUNet vsmlrt plugin by creating a single engine for resolutions from 8x8 to 4096x4096. I then tried it with clips ranging from 176x144 to 4K input, and it worked perfectly without needing to rebuild the TensorRT engine. The dynamic engine did its job as expected. I assume that DPIR and the other internal vsmlrt filters are working correctly too.

However, I'm getting a syntax-related error in the resize section; please see the screenshot and the error text.
[Image: EGRr4o-Zj8p.png]
# Imports
import vapoursynth as vs
# getting Vapoursynth core
import logging
import site
import sys
import os
core = vs.core
# Import scripts folder
scriptPath = 'C:/Program Files/Hybrid/64bit/vsscripts'
sys.path.insert(0, os.path.abspath(scriptPath))
os.environ["CUDA_MODULE_LOADING"] = "LAZY"
# Force logging to std:err
logging.StreamHandler(sys.stderr)
# loading plugins
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/vszip.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vs-mlrt/vstrt.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="C:/Program Files/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/LSMASHSource.dll")
# Import scripts
from importlib.machinery import SourceFileLoader
vsmlrt = SourceFileLoader('vsmlrt', 'C:/Program Files/Hybrid/64bit/vs-mlrt/vsmlrt.py').load_module()
from vsmlrt import Backend
import validate
# Source: 'F:\REMASTERIZACIJA\KLIPOVI ONLY BD\15.februar\davor\PRINC RIMA.AVI'
# Current color space: YUV422P8, bit depth: 8, resolution: 320x240, frame rate: 15fps, scanorder: progressive, yuv luminance scale: full, matrix: 470bg, format: JPEG
# Loading F:\REMASTERIZACIJA\KLIPOVI ONLY BD\15.februar\davor\PRINC RIMA.AVI using LWLibavSource
clip = core.lsmas.LWLibavSource(source="F:/REMASTERIZACIJA/KLIPOVI ONLY BD/15.februar/davor/PRINC RIMA.AVI", format="YUV422P8", stream_index=0, cache=0, prefer_hw=0)
frame = clip.get_frame(0)
# setting color matrix to 470bg.
clip = core.std.SetFrameProps(clip, _Matrix=vs.MATRIX_BT470_BG)
# setting color transfer (vs.TRANSFER_BT601), if it is not set.
if validate.transferIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Transfer=vs.TRANSFER_BT601)
# setting color primaries info (to vs.PRIMARIES_BT470_BG), if it is not set.
if validate.primariesIsInvalid(clip):
  clip = core.std.SetFrameProps(clip=clip, _Primaries=vs.PRIMARIES_BT470_BG)
# setting color range to PC (full) range.
clip = core.std.SetFrameProps(clip=clip, _ColorRange=vs.RANGE_FULL)
# making sure frame rate is set to 15fps
clip = core.std.AssumeFPS(clip=clip, fpsnum=15, fpsden=1)
# making sure the detected scan type is set (detected: progressive)
clip = core.std.SetFrameProps(clip=clip, _FieldBased=vs.FIELD_PROGRESSIVE) # progressive
# adjusting color space from YUV422P8 to RGBH for vsVSMLRT
clip = core.resize.Bicubic(clip=clip, format=vs.RGBH, matrix_in_s="470bg", range_in_s="full", range_s="full")
# resizing using VSMLRT, target: 640x480
clip = vsmlrt.inference([clip],network_path="D:/ONNX MODELI/2x_FeMaSR_SRX2_model_g-sim.onnx", backend=Backend.TRT(fp16=True,device_id=0,bf16=False,num_streams=1,verbose=True,use_cuda_graph=True,workspace=1073741824,builder_optimization_level=3,engine_folder="C:/Users/admin/Videos/HYBRIDMODELI",,static_shape=False,opt_shapes=[1280,1280],min_shapes=[8,8],max_shapes=[2560,2560])) # 640x480
# making sure 0-1 limits are respected
clip = core.vszip.Limiter(clip=clip, min=[0,0,0], max=[1,1,1])
# adjusting output color from: RGBH to YUV444P16 for FFV1Model
clip = core.resize.Bicubic(clip=clip, format=vs.YUV444P16, matrix_s="470bg", range_in_s="full", range_s="full") # additional resize to allow target color sampling
# set output frame rate to 15fps (progressive)
clip = core.std.AssumeFPS(clip=clip, fpsnum=15, fpsden=1)
# output
clip.set_output()


Quote:2025-09-07 20:09:39.260
Failed to evaluate the script:
Python exception: invalid syntax (tempPreviewVapoursynthFile20_09_39_120.vpy, line 47)
Traceback (most recent call last):
File "src/cython/vapoursynth.pyx", line 3364, in vapoursynth._vpy_evaluate
File "C:\Users\admin\AppData\Local\Temp\tempPreviewVapoursynthFile20_09_39_120.vpy", line 47
clip = vsmlrt.inference([clip],network_path="D:/ONNX MODELI/2x_FeMaSR_SRX2_model_g-sim.onnx", backend=Backend.TRT(fp16=True,device_id=0,bf16=False,num_streams=1,verbose=True,use_cuda_graph=True,workspace=1073741824,builder_optimization_level=3,engine_folder="C:/Users/admin/Videos/HYBRIDMODELI",,static_shape=False,opt_shapes=[1280,1280],min_shapes=[8,8],max_shapes=[2560,2560])) # 640x480
^
SyntaxError: invalid syntax



 The same thing happens when I try to enable vsmlrt with dynamic dimensions under "VS-Others-Vsmlrt". I'm guessing it's a small and subtle bug in the code.

Let me know if you need a more detailed log. I have to admit, I forgot where the log-debug files are saved, but I do know how to enable the option in Hybrid Tongue
Reply


Messages In This Thread
RE: Feature Request: Dynamic TensorRT models and build options - by mikazmaj - 07.09.2025, 20:19

Forum Jump:


Users browsing this thread: 2 Guest(s)