| 8 | from keras.datasets import cifar10, mnist |
| 9 | |
| 10 | class ImageData: |
| 11 | |
| 12 | def __init__(self, load_size, channels): |
| 13 | self.load_size = load_size |
| 14 | self.channels = channels |
| 15 | |
| 16 | def image_processing(self, filename): |
| 17 | x = tf.read_file(filename) |
| 18 | x_decode = tf.image.decode_jpeg(x, channels=self.channels) |
| 19 | img = tf.image.resize_images(x_decode, [self.load_size, self.load_size]) |
| 20 | img = tf.cast(img, tf.float32) / 127.5 - 1 |
| 21 | |
| 22 | return img |
| 23 | |
| 24 | |
| 25 | def load_mnist(size=64): |