Trying to use topaz video ai (latest) from python... error loading models

Hi

I’m trying to use topaz video ai (latest 3.1.6) on windows 11 x64 with an nvidia gpu, from a python script… if I run the ffmpeg.exe command from a cmd with the paths set, it works fine, but if I run it from python using subprocess.run (also tried subprocess.Popen to no avail), it always comes up with an error loading models.

the code: import osfrom pathlib import Pathimport subprocessVEAI_FFMPEG_PATH = ' - Pastebin.com
output of script running: > python main.pyInput #0, mov,mp4,m4a,3gp,3g2,mj2, from '70726847363002729 - Pastebin.com

DxDiag.txt (100.4 KB)

It’s very unusual, I’m not sure if ffmpeg.exe (your executable) is requiring additional things usually in a shell environment (?) or if it’s reading the path incorrectly? It’s reading auth.tpz correctly though.

I’ve noticed a slight difference with mention of “openvino” when run from python script & “tensorrt” when run manually from cmd (which works), perhaps I need to specify something else?

any help is appreciated
thanks!

I’m on a very similar system.
I use subprocess.call(command) where command is a string with everything I would put in the command line. Works correctly for me.
Because I need another version of FFMPEG to convert to H265, I do not set PATH. I always use the full path to the version of FFMPEG I need in each command.

Have you set the system environment variables for TVAI?

Yes I’ve set both TVAI_MODEL_DATA_DIR & TVAI_MODEL_DIR

Here’s an example of a command string I use:
"G:\Program Files\Topaz Labs LLC\Topaz Video AI\ffmpeg.exe" -hide_banner -stats_period 2.0 -nostdin -y -i "E:\Dump\somedvd\B2_t00 pt2 ffvpy.mkv" -sws_flags spline+accurate_rnd+full_chroma_int -filter_complex scale=w=853:h=480,setsar=1,tvai_up=model=prob-3:scale=2.25:w=1920:h=1080:preblur=0:noise=0:details=0.05:halo=0.01:blur=0:compression=0.6:device=0:vram=1:instances=1,scale=w=1920:h=1080:flags=lanczos:threads=0:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color=black -c:v png -pix_fmt rgb24 "E:\Dump\somedvd\B2_t00 pt2 ffvpyprot\%6d.png"
That’s the non-escaped string that gets printed out with the print function.
In the code there’s a lot of parsing and such:

command = TVAI + ' -hide_banner -stats_period 2.0 -nostdin -y -i "' \
        + os.path.join(filepath['-path'], filename + fext) + '"' + filt + ' -filter_complex scale=w=' + \
        filepath['-w'] + ':h=' + filepath['-h'] + ',setsar=1,tvai_up=model=prob-3:scale=2.25:w=1920:h=1080:prebl' \
        'ur=' + protpreblur + ':noise=' + protnoise + ':details=' + protdetails + ':halo=' + prothalo + ':blur=' + \
        protblur + ':compression=' + protcompression + ':device=0:vram=1:instances=1,scale=' \
        'w=1920:h=1080:flags=lanczos:threads=0:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1:color' \
        '=black -c:v png -pix_fmt rgb24 "' + os.path.join(outpath[0], outpath[1]) + '\\%6d.png"'

Try out a variation of that on your machine. If you still get the same issue, then I have no idea what’s going on.

My python script has multiprocessing setup so that I can have as many instances of TVAI running as I want. I did try piping the output from vapoursynth directly into TVAI with Python, and I never got it working. Seems it cannot call a pipe from Python. Or, I didn’t want to take the time to figure out how to get it working.