def _read_from_disk_spatial(fpath, nframes, num_samples=25, 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, dtype='int32')[0]
else:
step = tf.cast((duration-tf.constant(1)) /
(tf.constant(num_samples-1)), 'int32')
allimgs = []
with tf.variable_scope('read_rgb_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_rgb_image'):
prefix = file_prefix + '_' if file_prefix else ''
impath = tf.string_join([
tf.constant(dataset_dir + '/'),
fpath, tf.constant('/'),
prefix,
tf.as_string(start_frame + i * step + file_index,
width=file_zero_padding, fill='0'),
tf.constant('.jpg')])
img_str = tf.read_file(impath)
allimgs.append(img_str)
return allimgs
评论列表
文章目录