summaryrefslogtreecommitdiff
path: root/libavfilter/dnn
Commit message (Collapse)AuthorAge
* dnn/native: add native support for minimumGuo, Yejun2020-05-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it can be tested with model file generated with below python script: import tensorflow as tf import numpy as np import imageio in_img = imageio.imread('input.jpg') in_img = in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :] x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in') x1 = tf.minimum(0.7, x) x2 = tf.maximum(x1, 0.4) y = tf.identity(x2, name='dnn_out') sess=tf.Session() sess.run(tf.global_variables_initializer()) graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False) print("image_process.pb generated, please use \ path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n") output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg", np.squeeze(output)) Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
* dnn/native: add native support for divideGuo, Yejun2020-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it can be tested with model file generated with below python script: import tensorflow as tf import numpy as np import imageio in_img = imageio.imread('input.jpg') in_img = in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :] x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in') z1 = 2 / x z2 = 1 / z1 z3 = z2 / 0.25 + 0.3 z4 = z3 - x * 1.5 - 0.3 y = tf.identity(z4, name='dnn_out') sess=tf.Session() sess.run(tf.global_variables_initializer()) graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False) print("image_process.pb generated, please use \ path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n") output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg", np.squeeze(output)) Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
* dnn/native: add native support for 'mul'Guo, Yejun2020-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | it can be tested with model file generated from above python script: import tensorflow as tf import numpy as np import imageio in_img = imageio.imread('input.jpg') in_img = in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :] x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in') z1 = 0.5 + 0.3 * x z2 = z1 * 4 z3 = z2 - x - 2.0 y = tf.identity(z3, name='dnn_out') sess=tf.Session() sess.run(tf.global_variables_initializer()) graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False) print("image_process.pb generated, please use \ path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n") output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg", np.squeeze(output)) Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
* dnn/native: add native support for 'add'Guo, Yejun2020-04-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It can be tested with the model file generated with below python script: import tensorflow as tf import numpy as np import imageio in_img = imageio.imread('input.jpg') in_img = in_img.astype(np.float32)/255.0 in_data = in_img[np.newaxis, :] x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in') z1 = 0.039 + x z2 = x + 0.042 z3 = z1 + z2 z4 = z3 - 0.381 z5 = z4 - x y = tf.math.maximum(z5, 0.0, name='dnn_out') sess=tf.Session() sess.run(tf.global_variables_initializer()) graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out']) tf.train.write_graph(graph_def, '.', 'image_process.pb', as_text=False) print("image_process.pb generated, please use \ path_to_ffmpeg/tools/python/convert.py to generate image_process.model\n") output = sess.run(y, feed_dict={x: in_data}) imageio.imsave("out.jpg", np.squeeze(output)) Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
* dnn_backend_native_layer_mathbinary: add sub supportGuo, Yejun2020-04-07
| | | | | | more math binary operations will be added here Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
* lavf, lavfi: Remove uses of sizeof(char).Carl Eugen Hoyos2020-04-04
| | | | The C standard requires sizeof(char) == 1.
* avfilter/dnn: add a new interface to query dnn model's input infoGuo, Yejun2019-10-30
| | | | | | | | | | | | to support dnn networks more general, we need to know the input info of the dnn model. background: The data type of dnn model's input could be float32, uint8 or fp16, etc. And the w/h of input image could be fixed or variable. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* avfilter/dnn: get the data type of network output from dnn execution resultGuo, Yejun2019-10-30
| | | | | | | | | | | so, we can make a filter more general to accept different network models, by adding a data type convertion after getting data from network. After we add dt field into struct DNNData, it becomes the same as DNNInputData, so merge them with one struct: DNNData. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* dnn: add tf.nn.conv2d support for native modelGuo, Yejun2019-10-30
| | | | | | | | | | | | | Unlike other tf.*.conv2d layers, tf.nn.conv2d does not create many nodes (within a scope) in the graph, it just acts like other layers. tf.nn.conv2d only creates one node in the graph, and no internal nodes such as 'kernel' are created. The format of native model file is also changed, a flag named has_bias is added, so change the version number. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* avfilter/dnn: unify the layer load function in native modeGuo, Yejun2019-10-15
| | | | | Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* avfilter/dnn: unify the layer execution function in native modeGuo, Yejun2019-10-15
| | | | | Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* avfilter/dnn: add DLT prefix for enum DNNLayerType to avoid potential conflictsGuo, Yejun2019-10-15
| | | | | | | and also change CONV to DLT_CONV2D for better description Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn: support multiple outputs for native modeGuo, Yejun2019-09-20
| | | | | Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn/dnn_backend_native: find the input operand according to ↵Guo, Yejun2019-09-20
| | | | | | | input name Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn: add layer maximum for native mode.Guo, Yejun2019-09-20
| | | | | | | | | The reason to add this layer is that it is used by srcnn in vf_sr. This layer is currently ignored in native mode. After this patch, we can add multiple outputs support for native mode. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* avfilter/dnn: fix inclusion guard in dnn/dnn_backend_native_layer_depth2space.hMarton Balint2019-09-19
| | | | | | Fixes fate-source failure. Signed-off-by: Marton Balint <cus@passwd.hu>
* libavfilter/dnn: separate depth_to_space layer from dnn_backend_native.c to ↵Guo, Yejun2019-09-19
| | | | | | | | | | a new file the logic is that one layer in one separated source file to make the source files simple for maintaining. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn: separate conv2d layer from dnn_backend_native.c to a new fileGuo, Yejun2019-09-19
| | | | | | | | the logic is that one layer in one separated source file to make the source files simple for maintaining. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn: add header into native model fileGuo, Yejun2019-09-04
| | | | | Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* dnn: export operand info in python script and load in c codeGuo, Yejun2019-08-30
| | | | | Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* dnn: change .model file format to put layer number at the end of fileGuo, Yejun2019-08-30
| | | | | | | | | | currently, the layer number is at the beginning of the .model file, so we have to scan twice in python script, the first scan to get the layer number. Only one scan needed after put the layer number at the end of .model file. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* dnn: introduce dnn operand (in c code) to hold operand infos within networkGuo, Yejun2019-08-30
| | | | | | | | | | | the info can be saved in dnn operand object without regenerating again and again, and it is also needed for layer split/merge, and for memory reuse. to make things step by step, this patch just focuses on c code, the change within python script will be added later. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* lavfi/dnn/dnn_backend_native: fix memory leak in error pathJun Zhao2019-08-20
| | | | | | | fix memory leak in error path Reviewed-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* libavfilter/dnn/dnn_backend_tf: add tf.pad support for tensorflow backend ↵Guo, Yejun2019-08-19
| | | | | | | with native model. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn/dnn_backend_tf: fix typo that variable uninitialized.Guo, Yejun2019-08-19
| | | | | | | | | if it is initialized randomly, the tensorflow lib will report error message such as: Attempt to add output -7920 of depth_to_space4 not in range [0, 1) to node with type Identity Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* dnn: convert tf.pad to native model in python script, and load/execute it in ↵Guo, Yejun2019-07-29
| | | | | | | | | the c code. since tf.pad is enabled, the conv2d(valid) changes back to its original behavior. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* dnn: add layer pad which is equivalent to tf.padGuo, Yejun2019-07-29
| | | | | | | | | the reason to add this layer first is that vf_sr uses it in its tensorflow model, and the next plan is to update the python script to convert tf.pad into native model. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
* libavfilter/dnn: move dnn files from libavfilter to libavfilter/dnnGuo, Yejun2019-07-26
it is expected that there will be more files to support native mode, so put all the dnn codes under libavfilter/dnn The main change of this patch is to move the file location, see below: modified: libavfilter/Makefile new file: libavfilter/dnn/Makefile renamed: libavfilter/dnn_backend_native.c -> libavfilter/dnn/dnn_backend_native.c renamed: libavfilter/dnn_backend_native.h -> libavfilter/dnn/dnn_backend_native.h renamed: libavfilter/dnn_backend_tf.c -> libavfilter/dnn/dnn_backend_tf.c renamed: libavfilter/dnn_backend_tf.h -> libavfilter/dnn/dnn_backend_tf.h renamed: libavfilter/dnn_interface.c -> libavfilter/dnn/dnn_interface.c Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>