level 2
[Burst Denoising with Kernel Prediction Networks]文章是这个
kpn算法
2019年05月01日 08点05分
2
level 2
步入正题,看代码
def load_batch_hqjitter(dataset_dir, patches_per_img=32, min_queue=8, BURST_LENGTH=1, batch_size=32,
repeats=1, height=64, width=64, degamma=1.,
to_shift=1., upscale=1, jitter=1, smalljitter=1):
filenames = [os.path.join(dataset_dir, f) for f in gfile.ListDirectory(dataset_dir)]#gfile.ListDirectory()罗列data_dir目录下的所有文件并以列表形式返回,该行代码最终的结果为每张图片的路径
filename_queue = tf.train.string_input_producer(filenames)#管理文件列表并创建队列(用于读取数据)
_, image_file = tf.WholeFileReader().read(filename_queue)#读数据
image = tf.image.decode_image(image_file)#decode_bmp,decode_gif,decode_jpeg和decode_png的方便函数。检测图像是否为BMP,GIF,JPEG或PNG,并执行相应的操作将输入字节string转换为类型uint8的Tensor decode_gif返回一个4维数组[num_frames、高度、宽度、3],decode_bmp、decode_jpeg和decode_png返回3维数组[height, width, num_channels].
#tf.cast()数据转换
patches = make_stack_hqjitter((tf.cast(image[0], tf.float32) / 255.)**degamma,
height, width, patches_per_img, BURST_LENGTH, to_shift, upscale, jitter)
unique = batch_size//repeats
# Batch it up.
patches = tf.train.shuffle_batch(
[patches],
batch_size=unique,
num_threads=2,
capacity=min_queue + 3 * batch_size,
enqueue_many=True,
min_after_dequeue=min_queue)
print('PATCHES =================',patches.get_shape().as_list())
patches = make_batch_hqjitter(patches, BURST_LENGTH, batch_size, repeats, height, width, to_shift, upscale, jitter, smalljitter)
return patches
2019年05月01日 08点05分
3
level 2
我的问题主要是这3行
_, image_file = tf.WholeFileReader().read(filename_queue)
image = tf.image.decode_image(image_file)
patches = make_stack_hqjitter((tf.cast(image[0], tf.float32) / 255.)**degamma,
height, width, patches_per_img, BURST_LENGTH, to_shift, upscale, jitter)
2019年05月01日 08点05分
5
level 2
我的理解是读取队列中的图像,然后解码,(图像是jpg)解码后image就是一个(h,w,c)的三维张量。大佬们看看我这样理解对不对
2019年05月01日 08点05分
6
level 2
然后问题来了make_stack_hqjitter()中传入的参数是(tf.cast(image[0], tf.float32) / 255.)**degamma,
image[0],image[0]代表的不就是第一行的(w,c)?
2019年05月01日 08点05分
7
level 2
传这个有毛用,接下来去看看make_stack_hqjitter这个函数,
def make_stack_hqjitter(image, height, width, depth, BURST_LENGTH, to_shift, upscale, jitter):
j_up = jitter * upscale
h_up = height * upscale + 2 * j_up
w_up = width * upscale + 2 * j_up
v_error = tf.maximum((h_up - tf.shape(image)[0] + 1) // 2, 0)
h_error = tf.maximum((w_up - tf.shape(image)[1] + 1) // 2, 0)
image = tf.pad(image, [[v_error, v_error],[h_error,h_error],[0,0]])
stack = []
for i in range(depth):
stack.append(tf.random_crop(image, [h_up, w_up, 3]))#随机切割
stack = tf.stack(stack, axis=0)
return stack
2019年05月01日 08点05分
8
level 2
image = tf.pad(image, [[v_error, v_error],[h_error,h_error],[0,0]])从这一行可以看出传入的参数应该是一个三维的。我去!这是什么鬼!!!!!!!!!!!!!!!传入的参数明明是一个二维的,前后矛盾啦!!!!!!
2019年05月01日 08点05分
9
level 2
这么久了还没大佬来?????我卡在这里几天了。一直不明白
2019年05月01日 08点05分
11