1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
FFmpeg/doc
Guo, Yejun 4d980a8ceb avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks
This filter accepts all the dnn networks which do image processing.
Currently, frame with formats rgb24 and bgr24 are supported. Other
formats such as gray and YUV will be supported next. The dnn network
can accept data in float32 or uint8 format. And the dnn network can
change frame size.

The following is a python script to halve the value of the first
channel of the pixel. It demos how to setup and execute dnn model
with python+tensorflow. It also generates .pb file which will be
used by ffmpeg.

import tensorflow as tf
import numpy as np
import imageio
in_img = imageio.imread('in.bmp')
in_img = in_img.astype(np.float32)/255.0
in_data = in_img[np.newaxis, :]
filter_data = np.array([0.5, 0, 0, 0, 1., 0, 0, 0, 1.]).reshape(1,1,3,3).astype(np.float32)
filter = tf.Variable(filter_data)
x = tf.placeholder(tf.float32, shape=[1, None, None, 3], name='dnn_in')
y = tf.nn.conv2d(x, filter, strides=[1, 1, 1, 1], padding='VALID', name='dnn_out')
sess=tf.Session()
sess.run(tf.global_variables_initializer())
output = sess.run(y, feed_dict={x: in_data})
graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out'])
tf.train.write_graph(graph_def, '.', 'halve_first_channel.pb', as_text=False)
output = output * 255.0
output = output.astype(np.uint8)
imageio.imsave("out.bmp", np.squeeze(output))

To do the same thing with ffmpeg:
- generate halve_first_channel.pb with the above script
- generate halve_first_channel.model with tools/python/convert.py
- try with following commands
  ./ffmpeg -i input.jpg -vf dnn_processing=model=halve_first_channel.model:input=dnn_in:output=dnn_out:fmt=rgb24:dnn_backend=native -y out.native.png
  ./ffmpeg -i input.jpg -vf dnn_processing=model=halve_first_channel.pb:input=dnn_in:output=dnn_out:fmt=rgb24:dnn_backend=tensorflow -y out.tf.png

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
2019-11-07 15:46:00 -03:00
..
doxy Merge commit '257f00ec1ab06a2a161f535036c6512f3fc8e801' 2016-06-22 11:28:51 +02:00
examples doc/examples/muxing: fix underflow in duration of encoded streams 2019-09-29 20:41:29 +02:00
.gitignore Merge commit '257f00ec1ab06a2a161f535036c6512f3fc8e801' 2016-06-22 11:28:51 +02:00
APIchanges doc/APIchanges: add missing entry for the new runtime param AVOption flag 2019-10-14 12:05:01 -03:00
authors.texi
bitstream_filters.texi doc/bitstream_filters: Fix copy an paste typo 2019-11-05 21:21:32 +01:00
bootstrap.min.css
build_system.txt doc/build_system: Document checkheaders/alltools and consistency fixes 2019-05-28 09:12:17 +08:00
codecs.texi doc/codecs: Update documentation for flags/flags2 2019-10-06 17:33:00 +08:00
decoders.texi avcodec/libdav1d: use the library default for the filmgrain option 2019-09-15 11:09:39 -03:00
default.css
demuxers.texi lavf/hls: add http_seekable option for HTTP partial requests 2019-08-08 17:53:32 +08:00
developer.texi doc/developer: update style guidelines to include for loops with declarations 2018-05-18 02:24:28 +01:00
devices.texi
doxy-wrapper.sh doc: make apidoc output independent of SRC_PATH 2016-01-02 12:11:36 +01:00
Doxyfile doc: fix spelling errors 2016-10-21 23:58:47 +02:00
encoders.texi doc/encoders: Document eld_v2 option for libfdk_aac encoder. 2019-05-28 09:12:17 +08:00
errno.txt doc/errno: fix description typo for ENAMETOOLONG 2015-12-18 04:04:14 +01:00
faq.texi doc/faq: update macOS and URLs 2019-02-11 10:13:31 +05:30
fate_config.sh.template Merge commit '35d1f726eb9fdd376ab900587fb02122b72f2b9a' 2017-05-05 09:27:18 +02:00
fate.texi doc/fate: Document how to request samples upload access 2019-08-09 01:33:49 +02:00
ffmpeg-bitstream-filters.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-codecs.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-devices.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-filters.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-formats.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-protocols.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-resampler.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-scaler.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-utils.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg.texi doc/ffmpeg: -timelimit is in user time 2019-09-27 12:11:39 -08:00
ffmpeg.txt
ffplay.texi ffplay: added option always on top for video window 2019-05-20 17:51:43 -03:00
ffprobe.texi doc/ffprobe: fix typo and update URL in man 2019-02-09 20:01:18 +01:00
ffprobe.xsd fftools/ffprobe: Add S12M Timecode output as side data (such as SEI TC) 2019-05-27 00:28:34 +02:00
fftools-common-opts.texi doc/fftools-common-opts: document ffmpeg -h bsf=bitstream_filter_name 2019-06-14 13:19:26 +08:00
filter_design.txt doc: update filter_design.txt. 2017-09-12 11:03:51 +02:00
filters.texi avfilter/vf_dnn_processing: add a generic filter for image proccessing with dnn networks 2019-11-07 15:46:00 -03:00
formats.texi avformat: Add max_probe_packets option 2019-11-03 11:52:32 +01:00
general.texi lavc/g729dec: Support decoding Sipro ACELP.KELVIN. 2019-09-16 20:57:53 +02:00
git-howto.texi Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb' 2016-06-21 21:55:34 +02:00
indevs.texi doc/indevs: Add new option and example to avfoundation. 2019-07-08 20:02:41 +02:00
issue_tracker.txt Remove the ffserver program 2018-01-06 18:31:37 +00:00
lexicon doc: add a lexicon 2017-02-03 15:03:44 +01:00
libav-merge.txt doc/libav-merge: add a line about the previous skipped merge 2019-02-20 13:51:19 -03:00
libavcodec.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavdevice.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavfilter.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavformat.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavutil.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libswresample.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libswscale.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
mailing-list-faq.texi doc/mailing-list-faq: auto unsubscribe due to DMARC 2019-04-20 13:55:39 -08:00
Makefile doc: Add mailing list FAQ 2017-10-03 15:25:07 -08:00
metadata.texi doc/metadata: fix error in timebase description 2018-12-14 12:57:34 +01:00
mips.txt
multithreading.txt
muxers.texi doc: fix typo in muxers documentation 2019-10-30 11:10:25 +01:00
nut.texi Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb' 2016-06-21 21:55:34 +02:00
optimization.txt build: Prefer NASM assembler over YASM 2017-06-21 17:00:30 -03:00
outdevs.texi lavd: Remove libndi_newtek 2019-03-20 10:42:10 +00:00
patchwork doc/patchwork: Document the patchwork states 2016-10-26 19:46:00 +02:00
platform.texi configure: error out on unsupported MSVC versions 2018-05-18 02:22:57 +01:00
print_options.c Merge commit '2025d3787158ba272a1b8fbc0493fa20dd7a8484' 2017-03-29 15:20:10 +02:00
protocols.texi avformat/ftp: add AVOptions for authentication 2019-11-03 12:24:19 +01:00
rate_distortion.txt
resampler.texi swresample/options: enable linear_interp and exact_rational by default 2017-03-17 00:08:03 +07:00
scaler.texi doc/swscaler: explain default Lanczos parameter 2019-05-27 21:32:33 +05:30
snow.txt doc/snow: fix typos 2019-02-10 16:46:56 +01:00
style.min.css
swresample.txt
swscale.txt cosmetics: Fix spelling mistakes 2016-05-04 18:16:21 +02:00
t2h.init doc/t2h: use container 2016-10-03 00:16:27 +01:00
t2h.pm doc/t2h: use container 2016-10-03 00:16:27 +01:00
tablegen.txt
texi2pod.pl doc: escape left brace in texi2pod.pl regex 2016-07-10 13:34:57 +02:00
texidep.pl
undefined.txt doc: Add initial documentation explaining undefined behavior and SUINT 2017-07-21 17:37:05 +02:00
utils.texi doc/utils: add hexadecagonal channel layout 2019-10-19 13:00:36 +05:30
writing_filters.txt doc/writing_filters: Use ff_filter_get_nb_threads() get number of threads 2019-05-22 17:43:41 +08:00