styler00dollar / VSGAN-tensorrt-docker

Using VapourSynth with super resolution and interpolation models and speeding them up with TensorRT.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to parse script: Python exception: operator(): no valid optimization profile found

yuvraj108c opened this issue · comments

Apologies for creating another issue, but I'm not understanding why my realesrgan engine is only working with landscape aspect ratio videos.

I compiled the engine using this command:

trtexec --fp16 --onnx=model.onnx --minShapes=input:1x3x8x8 --optShapes=input:1x3x720x1280 --maxShapes=input:1x3x720x1280 --saveEngine=model.engine --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LT --skipInference

I thought it would upscale any videos (portrait/landscape) with dynamic widths and heights upto 1280px, but it is not working as expected.

Aspect ratio 16:9 works as expected upto 1280px with any dimensions
Aspect ratio 9:16 doesn't work above 360x640 (w x h)
Aspect ratio: 1:1 doesn't work above 360x360

What command should I use to make the engine work with every combination of dimensions upto 1280px?

Thanks for your help. Keep up the good work!

This works for portrait videos, but not landscape:

trtexec --fp16 --onnx=model.onnx --minShapes=input:1x3x8x8 --optShapes=input:1x3x1280x720 --maxShapes=input:1x3x1280x720 --saveEngine=model.engine --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LT --skipInference

@yuvraj108c Portrait videos on mobile sometimes arent really vertical, it's just metadata that rotates the image. That's probably the issue.

@yuvraj108c Portrait videos on mobile sometimes arent really vertical, it's just metadata that rotates the image. That's probably the issue.

I was just wrote portrait/landscape instead of aspect ratio, i'm not actually using videos taken from mobile phones.
I'm using videos on my pc with aspect ratio 9:16 & 16:9 (e.g 960x540 or 576x1024)

Currently, I built 2 different engines using the 2 commands above for these 2 aspect ratios and switch dynamically based on the video, not sure what is the issue.

This works for portrait videos, but not landscape:

trtexec --fp16 --onnx=model.onnx --minShapes=input:1x3x8x8 --optShapes=input:1x3x1280x720 --maxShapes=input:1x3x1280x720 --saveEngine=model.engine --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LT --skipInference

Well yeah, of course it won't lol

Height & width are flipped in shape input, so if you try doing 960x540 with that for example it won't work because 960 > 720.

If you have enough VRAM, just build large enough engine so everything fits (eg. 1x3x1080x1920), then you won't need to switch as long as the resolution is under 1920x1080.

commented

It should work with every shape that is within the bounds. Created a cugan 2x engine with:

trtexec --fp16 --bf16 --onnx=cugan_pro-denoise3x-up2x_op18_fp16_clamp_colorfix.onnx --minShapes=input:1x3x8x8 --optShapes=input:1x3x1280x720 --maxShapes=input:1x3x1280x720 --saveEngine=cugan_pro-denoise3x-up2x_op18_fp16_clamp_colorfix_8x8_720p.engine --tacticSources=+CUDNN,-CUBLAS,-CUBLAS_LT --skipInference

To test Aspect ratio 9:16 doesn't work above 360x640 (w x h) I tested vs.core.resize.Bicubic(clip, width=396, height=704, format=vs.RGBH, matrix_in_s="709") and it works.

To test Aspect ratio: 1:1 doesn't work above 360x360 I tested vs.core.resize.Bicubic(clip, width=720, height=720, format=vs.RGBH, matrix_in_s="709") and it works.

Both work because both stay below 720px.

width=960, height=540 throws vapoursynth.Error: operator(): no valid optimization profile found because the max width in the engine was 720. vs.core.resize.Bicubic(clip, width=540, height=960, format=vs.RGBH, matrix_in_s="709") works fine.

Everything seems to work as intended. Like @mafiosnik777 already said, check for rotation metadata and ensure you are within the engine bounds.

Thanks for clarifying! It now makes sense!