使用ID-CNN的SAR图像去斑

时间:2019-03-05 15:25:34

标签: python tensorflow deep-learning

我将使用ID-CNN网络进行SAR图像去斑。

我在https://github.com/RaymondByc/idcnn分叉。训练后,我可以看到张量板的结果。它看起来像右侧图像一样训练有素。但是当Mode在model.py中是“测试”(右侧图像)时,我没有去斑点图像用于输出。我猜“测试”代码有问题,但是我找不到错误。请帮助我。

图像-enter image description here]

    elif MODE == 'test':
    max_step = min(examples.steps_per_epoch, max_step)
    for step in range(max_step):
        results = sess.run(display_fetch)

        filesets = save_images(results)
        for i, f in enumerate(filesets):
            print("evaluated image", f["name"])
        index_path = append_index(filesets)

    print("wrote index at", index_path)

Examples = collections.namedtuple("Examples", "paths, inputs, targets, count, steps_per_epoch")

我将向您展示display_fetch。

with tf.name_scope("encode_image"):
display_fetch = {
    "paths:" : examples.paths,
    "inputs:" : tf.map_fn(tf.image.encode_png, convert_inputs, dtype=tf.string, name="input_pngs"),
    "outputs:": tf.map_fn(tf.image.encode_png, convert_outputs, dtype=tf.string, name="output_pngs"),
    "targets:": tf.map_fn(tf.image.encode_png, convert_targets, dtype=tf.string, name="targets_pngs"),
}

和save_images函数

def save_images(fetches, step=None):
image_dir = os.path.join(OUTDIR, "images")
if not os.path.exists(image_dir):
    os.makedirs(image_dir)

filesets = []
for i, in_path in enumerate(fetches["paths:"]):
    name, _ = os.path.splitext(os.path.basename(in_path.decode("utf8")))
    fileset = {"name": name, "step": step}
    for kind in ["inputs:","outputs:", "targets:"]:
        filename = name + "-" + kind + ".png"
        if step is not None:
            filename = "%08d-%s" % (step, filename)
        fileset[kind] = filename
        out_path = os.path.join(image_dir, filename)
        contents = fetches[kind][i]
        with open(out_path, "wb") as f:
            f.write(contents)
    filesets.append(fileset)
return filesets

0 个答案:

没有答案