MCPcopy Create free account
hub / github.com/cs230-stanford/cs230-code-examples / _parse_function

Function _parse_function

tensorflow/vision/model/input_fn.py:6–23  ·  view source on GitHub ↗

Obtain the image from the filename (for both training and validation). The following operations are applied: - Decode the image from jpeg format - Convert to float and to range [0, 1]

(filename, label, size)

Source from the content-addressed store, hash-verified

4
5
6def _parse_function(filename, label, size):
7 """Obtain the image from the filename (for both training and validation).
8
9 The following operations are applied:
10 - Decode the image from jpeg format
11 - Convert to float and to range [0, 1]
12 """
13 image_string = tf.read_file(filename)
14
15 # Don't use tf.image.decode_image, or the output shape will be undefined
16 image_decoded = tf.image.decode_jpeg(image_string, channels=3)
17
18 # This will convert to float values in [0, 1]
19 image = tf.image.convert_image_dtype(image_decoded, tf.float32)
20
21 resized_image = tf.image.resize_images(image, [size, size])
22
23 return resized_image, label
24
25
26def train_preprocess(image, label, use_random_flip):

Callers 1

input_fnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected