[FFmpeg-user] Leveraging TensorFlow and FFMPEG

Chen, Wenbin wenbin.chen at intel.com
Fri Apr 19 05:55:37 EEST 2024


You should add " "or ' ' to model path, because there is special character
in model path that breaks command line.
And you should also set input output name:
"dnn_backend=tensorflow:model=$MODEL_PATH:input=input_port_name:output=output_port_name "
 Please pay attention to the data format, ffmpeg-dnn tensorflow backend
passes data in format (RGB, NHWC and range(1.0f ~ 0.0f)) to tensorflow model.

I am not sure if .h5 model is supported since I only tried .pb model.

Best regards
Wenbin

> Hello All,
> 
> 
> 
> I am attempting to leverage Super-resolution from TensorFlow to enhance a
> video.
> 
> I used FFMPEG to split out each frame.  200K of them.
> 
> I then installed TensorFlow into my windows 11 pro system and verifies the
> install and path.
> 
> All good.
> 
> 
> 
> I downloaded a pre-trained model from Model Zoo.  Not sure if I even did
> this right as this is all very new and very complicated.  If anyone has
> experience with this stuff and can make a recommendation, that would be
> awesome!!.
> 
> 
> 
> I then wrote a simple script that should enhance the individual frames.
> 
> 
> 
> Script Start:
> 
> 
> 
> echo "Applying super resolution (SRGAN) to each frame..."
> 
> $MODEL_PATH =
> "C:\Super_Resolution\weights-srgan\weights\srgan\pre_generator.h5"
> 
> $OTHER_OPTIONS = ""
> 
> $files = Get-ChildItem *.png
> 
> $total_files = $files.Count
> 
> $current_file = 0
> 
> foreach ($file in $files) {
> 
>     $current_file++
> 
>     $progress = [math]::Round(($current_file / $total_files) * 100)
> 
>     echo "Processing file: $($file.Name) [$current_file/$total_files]
> ($progress%)"
> 
>     ffmpeg -i "$file" -vf
> dnn_processing=dnn_backend=tensorflow:model=$MODEL_PATH
> $OTHER_OPTIONS
> "enhanced_$($file.Name)"
> 
> }
> 
> 
> 
> Script End:
> 
> 
> 
> It is generating this error:
> 
> 
> 
> Input #0, png_pipe, from
> 'F:\Movies\Wholly_Moses\Temp_Work\frame_0001.png':
> 
>   Duration: N/A, bitrate: N/A
> 
>   Stream #0:0: Video: png, rgb24(pc, gbr/bt709/bt709), 1920x816 [SAR 1:1 DAR
> 40:17], 25 fps, 25 tbr, 25 tbn
> 
> [AVFilterGraph @ 000001c6d46bbc00] No option name near
> 'Super_Resolutionweights-srganweightssrganpre_generator.h5'
> 
> [AVFilterGraph @ 000001c6d46bbc00] Error parsing a filter description
> around:
> 
> [AVFilterGraph @ 000001c6d46bbc00] Error parsing filterchain
> 'dnn_processing=dnn_backend=tensorflow:model=C:\Super_Resolution\weig
> hts-srg
> an\weights\srgan\pre_generator.h5' around:
> 
> [vost#0:0/png @ 000001c6d46bcac0] Error initializing a simple filtergraph
> 
> Error opening output file enhanced_frame_0001.png.
> 
> Error opening output files: Invalid argument
> 
> 
> 
> I have altered the parameters for
> "dnn_processing=dnn_backend=tensorflow" a
> dozen different ways and it still generates the same error.
> 
> 
> 
> Would anyone be able to help me format a correct command syntax?
> 
> 
> 
> Please let me know if there is any other information needed to help answer
> this question.
> 
> 
> 
> Regards,
> 
> -Ron
> 
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list