import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import Image
import scipy.io
# load input and configure preprocessing
test_batch_mat_path='examples/Softmax/cifar-10-batches-mat/test_batch_mat'
i_test_batch_Obj = scipy.io.loadmat(test_batch_mat_path + '/test_batch.mat' )
X = i_test_batch_Obj.get('data').reshape((10000,3,32,32)).astype('float')
im = X[0,:,:,:].squeeze().transpose((1,2,0))
print im.shape
im = im[:, :, (2, 1, 0)]
print np.load('examples/Softmax/mean.npy').mean(1).mean(1)
transformer = caffe.io.Transformer({'data': net_softmax.blobs['data'].data.shape})
transformer.set_mean('data', np.load('examples/Softmax/mean.npy').mean(1).mean(1))
#transformer.set_mean('data', np.load('python/caffe/imagenet/ilsvrc_2012_mean.npy').mean(1).mean(1))
#transformer.set_mean('data', mean_arr[0]) # ImageNet mean
transformer.set_transpose('data', (2,0,1))
transformer.set_channel_swap('data',(2,1,0))#(2,1,0))
transformer.set_raw_scale('data',1.0)
# make classification map by forward and print prediction indices at each location
transformed_image = transformer.preprocess('data', im)
net_softmax.blobs['data'].data[...] = transformed_image
net_softmax.forward()