Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tensorflow as tf
- import numpy as np
- from scipy.misc import imread, imresize
- def preProcess(image):
- image = imresize(image, (224,224))
- mean = [123.68, 116.779, 103.939]
- images = image-mean
- return images
- img1 = imread('laska.png', mode = 'RGB')
- data = preProcess(img1)
- with open('input.txt', 'w') as outfile:
- # I'm writing a header here just for the sake of readability
- # Any line starting with "#" will be ignored by numpy.loadtxt
- #outfile.write('# Array shape: {0}\n'.format(data.shape))
- data_split = np.split(data, 3, axis = 2)
- outfile.write('%d %d %d' % (data.shape[0], data.shape[1], data.shape[2]))
- outfile.write('\n')
- for i in range(data.shape[2]):
- np.savetxt(outfile, data[...,i], fmt='%-15.7f')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement