??I was wondering how to make an imagenet_mean.binaryproto file on my own dataset while resizing it to 256X256 as it's done in compute_image_mean by using python code
imlist =[]
for root,_,files in os.walk(caffe_root+'data/ilsvrc12_vgg/Train'):
for f in files:
fullpath=os.path.join(root,f)
if fullpath[-4:] in [".png",".PNG",".jpg",".JPG",".JPEG"]:#get all the files in an image format into a list
imlist.append(fullpath)
#createAvgOfAllImg(imlist)
# Create a numpy array of floats to store the average (assume RGB images)
arr=np.zeros((256,256,3),np.float)
##############################################################################
# Build up average pixel intensities, casting each image as an array of floats
###########################################3##################################
N=len(imlist)
for im in imlist:
img= Image.open(im).resize(size,Image.ANTIALIAS)
imarr=np.array(img,dtype=np.float)
arr=arr+imarr/N
newarr=arr
# Round values in array and cast as 8-bit integer
#arr=np.array(np.round(arr),dtype=np.uint8)
######################################################
#making a binaryproto file consists of the mean values
######################################################
imagenet_vgg_mean=caffe_root+'data/ilsvrc12_vgg/imagenet_vgg_mean.binaryproto'
print "MAKING A BINARYPROTO FILE OF MEAN VALUES IN ",imagenet_vgg_mean
blob = caffe.io.array_to_blobproto( arr )
with open( imagenet_vgg_mean, 'wb' ) as f :
f.write( blob.SerializeToString() )
however, I see that the data in the binaryproto file made by compute_image_mean is different from the one I created..
I would like to get a code that created that well..