def main(_):
eps = FLAGS.max_epsilon / 255.0
batch_shape = [FLAGS.batch_size, FLAGS.image_height, FLAGS.image_width, 3]
with tf.Graph().as_default():
x_input = tf.placeholder(tf.float32, shape=batch_shape)
noisy_images = x_input + eps * tf.sign(tf.random_normal(batch_shape))
x_output = tf.clip_by_value(noisy_images, 0.0, 1.0)
with tf.Session(FLAGS.master) as sess:
for filenames, images in load_images(FLAGS.input_dir, batch_shape):
out_images = sess.run(x_output, feed_dict={x_input: images})
save_images(out_images, filenames, FLAGS.output_dir)
评论列表
文章目录