def _read_from_disk_temporal(
fpath, nframes, num_samples=25,
optical_flow_frames=10, start_frame=0,
file_prefix='', file_zero_padding=4, file_index=1,
dataset_dir='', step=None):
duration = nframes
if step is None:
if num_samples == 1:
step = tf.random_uniform([1], 0, nframes-optical_flow_frames-1, dtype='int32')[0]
else:
step = tf.cast((duration-tf.constant(optical_flow_frames)) /
(tf.constant(num_samples)), 'int32')
allimgs = []
with tf.variable_scope('read_flow_video'):
for i in range(num_samples):
if num_samples == 1:
i = 1 # so that the random step value can be used
with tf.variable_scope('read_flow_image'):
flow_img = []
for j in range(optical_flow_frames):
with tf.variable_scope('read_flow_channels'):
for dr in ['x', 'y']:
prefix = file_prefix + '_' if file_prefix else ''
impath = tf.string_join([
tf.constant(dataset_dir + '/'),
fpath, tf.constant('/'),
prefix, '%s_' % dr,
tf.as_string(start_frame + i * step + file_index + j,
width=file_zero_padding, fill='0'),
tf.constant('.jpg')])
img_str = tf.read_file(impath)
flow_img.append(img_str)
allimgs.append(flow_img)
return allimgs
评论列表
文章目录