MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / ImageTransformer

Class ImageTransformer

rl2/a3c/worker.py:23–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21# 2) Resize
22# 3) Crop
23class ImageTransformer:
24 def __init__(self):
25 with tf.variable_scope("image_transformer"):
26 self.input_state = tf.placeholder(shape=[210, 160, 3], dtype=tf.uint8)
27 self.output = tf.image.rgb_to_grayscale(self.input_state)
28 self.output = tf.image.crop_to_bounding_box(self.output, 34, 0, 160, 160)
29 self.output = tf.image.resize_images(
30 self.output,
31 [84, 84],
32 method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)
33 self.output = tf.squeeze(self.output)
34
35 def transform(self, state, sess=None):
36 sess = sess or tf.get_default_session()
37 return sess.run(self.output, { self.input_state: state })
38
39
40# Create initial state by repeating the same frame 4 times

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected