]> git.sesse.net Git - ffmpeg/commit
dnn_backend_tf.c: add option sess_config for tf backend
authorGuo, Yejun <yejun.guo@intel.com>
Mon, 12 Oct 2020 07:52:26 +0000 (15:52 +0800)
committerGuo, Yejun <yejun.guo@intel.com>
Mon, 19 Oct 2020 12:54:29 +0000 (20:54 +0800)
commitc4a3dbe726150d9217a4d3fed47b012839e33d82
treede495560d4e3d01908a78a83ad459c4b6bcab891
parent4ccb68dc670bbc98b4dede6f21615343dd46561e
dnn_backend_tf.c: add option sess_config for tf backend

TensorFlow C library accepts config for session options to
set different parameters for the inference. This patch exports
this interface.

The config is a serialized tensorflow.ConfigProto proto, so we need
two steps to use it:
1. generate the serialized proto with python (see script example below)
the output looks like: 0xab...cd
where 0xcd is the least significant byte and 0xab is the most significant byte.

2. pass the python script output into ffmpeg with
dnn_processing=options=sess_config=0xab...cd

The following script is an example to specify one GPU. If the system contains
3 GPU cards, the visible_device_list could be '0', '1', '2', '0,1' etc.
'0' does not mean physical GPU card 0, we need to try and see.
And we can also add more opitions here to generate more serialized proto.

script example to generate serialized proto which specifies one GPU:
import tensorflow as tf
gpu_options = tf.GPUOptions(visible_device_list='0')
config = tf.ConfigProto(gpu_options=gpu_options)
s = config.SerializeToString()
b = ''.join("%02x" % int(ord(b)) for b in s[::-1])
print('0x%s' % b)
libavfilter/dnn/dnn_backend_tf.c