• Guo, Yejun's avatar
    vf_dnn_processing: add support for more formats gray8 and grayf32 · 37d24a6c
    Guo, Yejun authored
    The following is a python script to halve the value of the gray
    image. 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
    from skimage import color
    from skimage import io
    in_img = io.imread('input.jpg')
    in_img = color.rgb2gray(in_img)
    io.imsave('ori_gray.jpg', np.squeeze(in_img))
    in_data = np.expand_dims(in_img, axis=0)
    in_data = np.expand_dims(in_data, axis=3)
    filter_data = np.array([0.5]).reshape(1,1,1,1).astype(np.float32)
    filter = tf.Variable(filter_data)
    x = tf.placeholder(tf.float32, shape=[1, None, None, 1], 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())
    graph_def = tf.graph_util.convert_variables_to_constants(sess, sess.graph_def, ['dnn_out'])
    tf.train.write_graph(graph_def, '.', 'halve_gray_float.pb', as_text=False)
    print("halve_gray_float.pb generated, please use \
    path_to_ffmpeg/tools/python/convert.py to generate halve_gray_float.model\n")
    output = sess.run(y, feed_dict={x: in_data})
    output = output * 255.0
    output = output.astype(np.uint8)
    io.imsave("out.jpg", np.squeeze(output))
    
    To do the same thing with ffmpeg:
    - generate halve_gray_float.pb with the above script
    - generate halve_gray_float.model with tools/python/convert.py
    - try with following commands
      ./ffmpeg -i input.jpg -vf format=grayf32,dnn_processing=model=halve_gray_float.model:input=dnn_in:output=dnn_out:dnn_backend=native out.native.png
      ./ffmpeg -i input.jpg -vf format=grayf32,dnn_processing=model=halve_gray_float.pb:input=dnn_in:output=dnn_out:dnn_backend=tensorflow out.tf.png
    Signed-off-by: 's avatarGuo, Yejun <yejun.guo@intel.com>
    Signed-off-by: 's avatarPedro Arthur <bygrandao@gmail.com>
    37d24a6c
Name
Last commit
Last update
..
aarch64 Loading commit data...
dnn Loading commit data...
opencl Loading commit data...
tests Loading commit data...
x86 Loading commit data...
.gitignore Loading commit data...
Makefile Loading commit data...
aeval.c Loading commit data...
af_acontrast.c Loading commit data...
af_acopy.c Loading commit data...
af_acrossover.c Loading commit data...
af_acrusher.c Loading commit data...
af_adeclick.c Loading commit data...
af_adelay.c Loading commit data...
af_aderivative.c Loading commit data...
af_aecho.c Loading commit data...
af_aemphasis.c Loading commit data...
af_afade.c Loading commit data...
af_afftdn.c Loading commit data...
af_afftfilt.c Loading commit data...
af_afir.c Loading commit data...
af_afir.h Loading commit data...
af_aformat.c Loading commit data...
af_agate.c Loading commit data...
af_aiir.c Loading commit data...
af_alimiter.c Loading commit data...
af_amerge.c Loading commit data...
af_amix.c Loading commit data...
af_amultiply.c Loading commit data...
af_anequalizer.c Loading commit data...
af_anlmdn.c Loading commit data...
af_anlmdndsp.h Loading commit data...
af_anlms.c Loading commit data...
af_anull.c Loading commit data...
af_apad.c Loading commit data...
af_aphaser.c Loading commit data...
af_apulsator.c Loading commit data...
af_aresample.c Loading commit data...
af_arnndn.c Loading commit data...
af_asetnsamples.c Loading commit data...
af_asetrate.c Loading commit data...
af_ashowinfo.c Loading commit data...
af_asoftclip.c Loading commit data...
af_asr.c Loading commit data...
af_astats.c Loading commit data...
af_atempo.c Loading commit data...
af_axcorrelate.c Loading commit data...
af_biquads.c Loading commit data...
af_bs2b.c Loading commit data...
af_channelmap.c Loading commit data...
af_channelsplit.c Loading commit data...
af_chorus.c Loading commit data...
af_compand.c Loading commit data...
af_compensationdelay.c Loading commit data...
af_crossfeed.c Loading commit data...
af_crystalizer.c Loading commit data...
af_dcshift.c Loading commit data...
af_deesser.c Loading commit data...
af_drmeter.c Loading commit data...
af_dynaudnorm.c Loading commit data...
af_earwax.c Loading commit data...
af_extrastereo.c Loading commit data...
af_firequalizer.c Loading commit data...
af_flanger.c Loading commit data...
af_haas.c Loading commit data...
af_hdcd.c Loading commit data...
af_headphone.c Loading commit data...
af_join.c Loading commit data...
af_ladspa.c Loading commit data...
af_loudnorm.c Loading commit data...
af_lv2.c Loading commit data...
af_mcompand.c Loading commit data...
af_pan.c Loading commit data...
af_replaygain.c Loading commit data...
af_resample.c Loading commit data...
af_rubberband.c Loading commit data...
af_sidechaincompress.c Loading commit data...
af_silencedetect.c Loading commit data...
af_silenceremove.c Loading commit data...
af_sofalizer.c Loading commit data...
af_stereotools.c Loading commit data...
af_stereowiden.c Loading commit data...
af_superequalizer.c Loading commit data...
af_surround.c Loading commit data...
af_tremolo.c Loading commit data...
af_vibrato.c Loading commit data...
af_volume.c Loading commit data...
af_volume.h Loading commit data...
af_volumedetect.c Loading commit data...
all_channel_layouts.inc Loading commit data...
allfilters.c Loading commit data...
asink_anullsink.c Loading commit data...
asrc_anoisesrc.c Loading commit data...
asrc_anullsrc.c Loading commit data...
asrc_flite.c Loading commit data...
asrc_hilbert.c Loading commit data...
asrc_sinc.c Loading commit data...
asrc_sine.c Loading commit data...
atadenoise.h Loading commit data...
audio.c Loading commit data...
audio.h Loading commit data...
avf_abitscope.c Loading commit data...
avf_ahistogram.c Loading commit data...
avf_aphasemeter.c Loading commit data...
avf_avectorscope.c Loading commit data...
avf_concat.c Loading commit data...
avf_showcqt.c Loading commit data...
avf_showcqt.h Loading commit data...
avf_showfreqs.c Loading commit data...
avf_showspatial.c Loading commit data...
avf_showspectrum.c Loading commit data...
avf_showvolume.c Loading commit data...
avf_showwaves.c Loading commit data...
avfilter.c Loading commit data...
avfilter.h Loading commit data...
avfiltergraph.c Loading commit data...
avfilterres.rc Loading commit data...
bbox.c Loading commit data...
bbox.h Loading commit data...
blend.h Loading commit data...
boxblur.c Loading commit data...
boxblur.h Loading commit data...
bufferqueue.h Loading commit data...
buffersink.c Loading commit data...
buffersink.h Loading commit data...
buffersrc.c Loading commit data...
buffersrc.h Loading commit data...
bwdif.h Loading commit data...
colorspace.c Loading commit data...
colorspace.h Loading commit data...
colorspacedsp.c Loading commit data...
colorspacedsp.h Loading commit data...
colorspacedsp_template.c Loading commit data...
colorspacedsp_yuv2yuv_template.c Loading commit data...
convolution.h Loading commit data...
deshake.h Loading commit data...
dnn_interface.h Loading commit data...
drawutils.c Loading commit data...
drawutils.h Loading commit data...
ebur128.c Loading commit data...
ebur128.h Loading commit data...
f_bench.c Loading commit data...
f_cue.c Loading commit data...
f_drawgraph.c Loading commit data...
f_ebur128.c Loading commit data...
f_graphmonitor.c Loading commit data...
f_interleave.c Loading commit data...
f_loop.c Loading commit data...
f_metadata.c Loading commit data...
f_perms.c Loading commit data...
f_realtime.c Loading commit data...
f_reverse.c Loading commit data...
f_select.c Loading commit data...
f_sendcmd.c Loading commit data...
f_sidedata.c Loading commit data...
f_streamselect.c Loading commit data...
f_zmq.c Loading commit data...
fifo.c Loading commit data...
filters.h Loading commit data...
formats.c Loading commit data...
formats.h Loading commit data...
framepool.c Loading commit data...
framepool.h Loading commit data...
framequeue.c Loading commit data...
framequeue.h Loading commit data...
framerate.h Loading commit data...
framesync.c Loading commit data...
framesync.h Loading commit data...
gblur.h Loading commit data...
generate_wave_table.c Loading commit data...
generate_wave_table.h Loading commit data...
gradfun.h Loading commit data...
graphdump.c Loading commit data...
graphparser.c Loading commit data...
hermite.h Loading commit data...
hflip.h Loading commit data...
internal.h Loading commit data...
lavfutils.c Loading commit data...
lavfutils.h Loading commit data...
libavfilter.v Loading commit data...
limiter.h Loading commit data...
log2_tab.c Loading commit data...
lswsutils.c Loading commit data...
lswsutils.h Loading commit data...
maskedclamp.h Loading commit data...
maskedmerge.h Loading commit data...
median.h Loading commit data...
median_template.c Loading commit data...
motion_estimation.c Loading commit data...
motion_estimation.h Loading commit data...
opencl.c Loading commit data...
opencl.h Loading commit data...
opencl_source.h Loading commit data...
psnr.h Loading commit data...
pthread.c Loading commit data...
qsvvpp.c Loading commit data...
qsvvpp.h Loading commit data...
removegrain.h Loading commit data...
scale_eval.c Loading commit data...
scale_eval.h Loading commit data...
scene_sad.c Loading commit data...
scene_sad.h Loading commit data...
setpts.c Loading commit data...
settb.c Loading commit data...
signature.h Loading commit data...
signature_lookup.c Loading commit data...
split.c Loading commit data...
src_movie.c Loading commit data...
ssim.h Loading commit data...
stereo3d.h Loading commit data...
thread.h Loading commit data...
threshold.h Loading commit data...
tinterlace.h Loading commit data...
transform.c Loading commit data...
transform.h Loading commit data...
transpose.h Loading commit data...
trim.c Loading commit data...
unsharp.h Loading commit data...
v360.h Loading commit data...
vaapi_vpp.c Loading commit data...
vaapi_vpp.h Loading commit data...
vaf_spectrumsynth.c Loading commit data...
version.h Loading commit data...
vf_addroi.c Loading commit data...
vf_alphamerge.c Loading commit data...
vf_amplify.c Loading commit data...
vf_aspect.c Loading commit data...
vf_atadenoise.c Loading commit data...
vf_avgblur.c Loading commit data...
vf_avgblur_opencl.c Loading commit data...
vf_bbox.c Loading commit data...
vf_bilateral.c Loading commit data...
vf_bitplanenoise.c Loading commit data...
vf_blackdetect.c Loading commit data...
vf_blackframe.c Loading commit data...
vf_blend.c Loading commit data...
vf_bm3d.c Loading commit data...
vf_boxblur.c Loading commit data...
vf_bwdif.c Loading commit data...
vf_chromakey.c Loading commit data...
vf_chromashift.c Loading commit data...
vf_ciescope.c Loading commit data...
vf_codecview.c Loading commit data...
vf_colorbalance.c Loading commit data...
vf_colorchannelmixer.c Loading commit data...
vf_colorconstancy.c Loading commit data...
vf_colorkey.c Loading commit data...
vf_colorkey_opencl.c Loading commit data...
vf_colorlevels.c Loading commit data...
vf_colormatrix.c Loading commit data...
vf_colorspace.c Loading commit data...
vf_convolution.c Loading commit data...
vf_convolution_opencl.c Loading commit data...
vf_convolve.c Loading commit data...
vf_copy.c Loading commit data...
vf_coreimage.m Loading commit data...
vf_cover_rect.c Loading commit data...
vf_crop.c Loading commit data...
vf_cropdetect.c Loading commit data...
vf_curves.c Loading commit data...
vf_datascope.c Loading commit data...
vf_dctdnoiz.c Loading commit data...
vf_deband.c Loading commit data...
vf_deblock.c Loading commit data...
vf_decimate.c Loading commit data...
vf_dedot.c Loading commit data...
vf_deflicker.c Loading commit data...
vf_deinterlace_qsv.c Loading commit data...
vf_deinterlace_vaapi.c Loading commit data...
vf_dejudder.c Loading commit data...
vf_delogo.c Loading commit data...
vf_derain.c Loading commit data...
vf_deshake.c Loading commit data...
vf_deshake_opencl.c Loading commit data...
vf_despill.c Loading commit data...
vf_detelecine.c Loading commit data...
vf_displace.c Loading commit data...
vf_dnn_processing.c Loading commit data...
vf_drawbox.c Loading commit data...
vf_drawtext.c Loading commit data...
vf_edgedetect.c Loading commit data...
vf_elbg.c Loading commit data...
vf_entropy.c Loading commit data...
vf_eq.c Loading commit data...
vf_eq.h Loading commit data...
vf_extractplanes.c Loading commit data...
vf_fade.c Loading commit data...
vf_fftdnoiz.c Loading commit data...
vf_fftfilt.c Loading commit data...
vf_field.c Loading commit data...
vf_fieldhint.c Loading commit data...
vf_fieldmatch.c Loading commit data...
vf_fieldorder.c Loading commit data...
vf_fillborders.c Loading commit data...
vf_find_rect.c Loading commit data...
vf_floodfill.c Loading commit data...
vf_format.c Loading commit data...
vf_fps.c Loading commit data...
vf_framepack.c Loading commit data...
vf_framerate.c Loading commit data...
vf_framestep.c Loading commit data...
vf_freezedetect.c Loading commit data...
vf_frei0r.c Loading commit data...
vf_fspp.c Loading commit data...
vf_fspp.h Loading commit data...
vf_gblur.c Loading commit data...
vf_geq.c Loading commit data...
vf_gradfun.c Loading commit data...
vf_hflip.c Loading commit data...
vf_histeq.c Loading commit data...
vf_histogram.c Loading commit data...
vf_hqdn3d.c Loading commit data...
vf_hqdn3d.h Loading commit data...
vf_hqx.c Loading commit data...
vf_hue.c Loading commit data...
vf_hwdownload.c Loading commit data...
vf_hwmap.c Loading commit data...
vf_hwupload.c Loading commit data...
vf_hwupload_cuda.c Loading commit data...
vf_hysteresis.c Loading commit data...
vf_idet.c Loading commit data...
vf_idet.h Loading commit data...
vf_il.c Loading commit data...
vf_kerndeint.c Loading commit data...
vf_lagfun.c Loading commit data...
vf_lenscorrection.c Loading commit data...
vf_lensfun.c Loading commit data...
vf_libopencv.c Loading commit data...
vf_libvmaf.c Loading commit data...
vf_limiter.c Loading commit data...
vf_lumakey.c Loading commit data...
vf_lut.c Loading commit data...
vf_lut2.c Loading commit data...
vf_lut3d.c Loading commit data...
vf_maskedclamp.c Loading commit data...
vf_maskedmerge.c Loading commit data...
vf_maskedminmax.c Loading commit data...
vf_maskfun.c Loading commit data...
vf_mcdeint.c Loading commit data...
vf_median.c Loading commit data...
vf_mergeplanes.c Loading commit data...
vf_mestimate.c Loading commit data...
vf_midequalizer.c Loading commit data...
vf_minterpolate.c Loading commit data...
vf_misc_vaapi.c Loading commit data...
vf_mix.c Loading commit data...
vf_mpdecimate.c Loading commit data...
vf_neighbor.c Loading commit data...
vf_neighbor_opencl.c Loading commit data...
vf_nlmeans.c Loading commit data...
vf_nlmeans.h Loading commit data...
vf_nlmeans_opencl.c Loading commit data...
vf_nnedi.c Loading commit data...
vf_noise.c Loading commit data...
vf_noise.h Loading commit data...
vf_normalize.c Loading commit data...
vf_null.c Loading commit data...
vf_ocr.c Loading commit data...
vf_overlay.c Loading commit data...
vf_overlay.h Loading commit data...
vf_overlay_opencl.c Loading commit data...
vf_overlay_qsv.c Loading commit data...
vf_owdenoise.c Loading commit data...
vf_pad.c Loading commit data...
vf_palettegen.c Loading commit data...
vf_paletteuse.c Loading commit data...
vf_perspective.c Loading commit data...
vf_phase.c Loading commit data...
vf_photosensitivity.c Loading commit data...
vf_pixdesctest.c Loading commit data...
vf_pp.c Loading commit data...
vf_pp7.c Loading commit data...
vf_pp7.h Loading commit data...
vf_premultiply.c Loading commit data...
vf_procamp_vaapi.c Loading commit data...
vf_program_opencl.c Loading commit data...
vf_pseudocolor.c Loading commit data...
vf_psnr.c Loading commit data...
vf_pullup.c Loading commit data...
vf_pullup.h Loading commit data...
vf_qp.c Loading commit data...
vf_random.c Loading commit data...
vf_readeia608.c Loading commit data...
vf_readvitc.c Loading commit data...
vf_remap.c Loading commit data...
vf_removegrain.c Loading commit data...
vf_removelogo.c Loading commit data...
vf_repeatfields.c Loading commit data...
vf_rotate.c Loading commit data...
vf_sab.c Loading commit data...
vf_scale.c Loading commit data...
vf_scale_cuda.c Loading commit data...
vf_scale_cuda.cu Loading commit data...
vf_scale_npp.c Loading commit data...
vf_scale_qsv.c Loading commit data...
vf_scale_vaapi.c Loading commit data...
vf_scroll.c Loading commit data...
vf_selectivecolor.c Loading commit data...
vf_separatefields.c Loading commit data...
vf_setparams.c Loading commit data...
vf_showinfo.c Loading commit data...
vf_showpalette.c Loading commit data...
vf_shuffleframes.c Loading commit data...
vf_shuffleplanes.c Loading commit data...
vf_signalstats.c Loading commit data...
vf_signature.c Loading commit data...
vf_smartblur.c Loading commit data...
vf_spp.c Loading commit data...
vf_spp.h Loading commit data...
vf_sr.c Loading commit data...
vf_ssim.c Loading commit data...
vf_stack.c Loading commit data...
vf_stereo3d.c Loading commit data...
vf_subtitles.c Loading commit data...
vf_super2xsai.c Loading commit data...
vf_swaprect.c Loading commit data...
vf_swapuv.c Loading commit data...
vf_telecine.c Loading commit data...
vf_threshold.c Loading commit data...
vf_thumbnail.c Loading commit data...
vf_thumbnail_cuda.c Loading commit data...
vf_thumbnail_cuda.cu Loading commit data...
vf_tile.c Loading commit data...
vf_tinterlace.c Loading commit data...
vf_tonemap.c Loading commit data...
vf_tonemap_opencl.c Loading commit data...
vf_tonemap_vaapi.c Loading commit data...
vf_tpad.c Loading commit data...
vf_transpose.c Loading commit data...
vf_transpose_npp.c Loading commit data...
vf_transpose_opencl.c Loading commit data...
vf_transpose_vaapi.c Loading commit data...
vf_unsharp.c Loading commit data...
vf_unsharp_opencl.c Loading commit data...
vf_uspp.c Loading commit data...
vf_v360.c Loading commit data...
vf_vaguedenoiser.c Loading commit data...
vf_vectorscope.c Loading commit data...
vf_vflip.c Loading commit data...
vf_vfrdet.c Loading commit data...
vf_vibrance.c Loading commit data...
vf_vidstabdetect.c Loading commit data...
vf_vidstabtransform.c Loading commit data...
vf_vignette.c Loading commit data...
vf_vmafmotion.c Loading commit data...
vf_vpp_qsv.c Loading commit data...
vf_w3fdif.c Loading commit data...
vf_waveform.c Loading commit data...
vf_weave.c Loading commit data...
vf_xbr.c Loading commit data...
vf_xmedian.c Loading commit data...
vf_yadif.c Loading commit data...
vf_yadif_cuda.c Loading commit data...
vf_yadif_cuda.cu Loading commit data...
vf_yaepblur.c Loading commit data...
vf_zoompan.c Loading commit data...
vf_zscale.c Loading commit data...
video.c Loading commit data...
video.h Loading commit data...
vidstabutils.c Loading commit data...
vidstabutils.h Loading commit data...
vmaf_motion.h Loading commit data...
vsink_nullsink.c Loading commit data...
vsrc_cellauto.c Loading commit data...
vsrc_life.c Loading commit data...
vsrc_mandelbrot.c Loading commit data...
vsrc_mptestsrc.c Loading commit data...
vsrc_sierpinski.c Loading commit data...
vsrc_testsrc.c Loading commit data...
w3fdif.h Loading commit data...
window_func.h Loading commit data...
yadif.h Loading commit data...
yadif_common.c Loading commit data...