def DataIOStream(raw_src: Flow): return (raw_src.Filter( lambda x: x.endswith('.jpg')) # select jpg files/选取jpg格式文件 .Map(lambda x: os.path.join(train_dir, x)) # 拿到ground truth数据 .Map(data.imread).Map(lambda im: [ im, mixed_noise(im), gaussian_noise(im), poisson_noise(im) ] | infix / Map @ img_as_float).Map(to_batch))
def DataIOStream(raw_src: Flow): return (raw_src.Filter( lambda x: x.endswith('.jpg')) # select jpg files/选取jpg格式文件 .Map(lambda x: [os.path.join(train_dir, x)] + [ os.path.join(test_dir, x[:-4] + "_" + str(i) + '.jpg') for i in range(1, 3) ]) # 将噪声数据和真实数据进行合并 .Map(lambda img_file_names: list( map( and_then( data.imread, # 读取图像 img_as_float), # 浮点数张量 [0, 255]->[0, 1] img_file_names))).Map(to_batch))