1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +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
examples doc/examples/muxing: fix underflow in duration of encoded streams 2019-09-29 20:41:29 +02:00
.gitignore
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
Doxyfile
encoders.texi doc/encoders: Document eld_v2 option for libfdk_aac encoder. 2019-05-28 09:12:17 +08:00
errno.txt
faq.texi doc/faq: update macOS and URLs 2019-02-11 10:13:31 +05:30
fate_config.sh.template
fate.texi doc/fate: Document how to request samples upload access 2019-08-09 01:33:49 +02:00
ffmpeg-bitstream-filters.texi
ffmpeg-codecs.texi
ffmpeg-devices.texi
ffmpeg-filters.texi
ffmpeg-formats.texi
ffmpeg-protocols.texi
ffmpeg-resampler.texi
ffmpeg-scaler.texi
ffmpeg-utils.texi
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
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
indevs.texi doc/indevs: Add new option and example to avfoundation. 2019-07-08 20:02:41 +02:00
issue_tracker.txt
lexicon
libav-merge.txt doc/libav-merge: add a line about the previous skipped merge 2019-02-20 13:51:19 -03:00
libavcodec.texi
libavdevice.texi
libavfilter.texi
libavformat.texi
libavutil.texi
libswresample.texi
libswscale.texi
mailing-list-faq.texi doc/mailing-list-faq: auto unsubscribe due to DMARC 2019-04-20 13:55:39 -08:00
Makefile
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
optimization.txt
outdevs.texi lavd: Remove libndi_newtek 2019-03-20 10:42:10 +00:00
patchwork
platform.texi configure: error out on unsupported MSVC versions 2018-05-18 02:22:57 +01:00
print_options.c
protocols.texi avformat/ftp: add AVOptions for authentication 2019-11-03 12:24:19 +01:00
rate_distortion.txt
resampler.texi
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
t2h.init
t2h.pm
tablegen.txt
texi2pod.pl
texidep.pl
undefined.txt
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