This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
import numpy as np | |
def create_hdf5_for_caffe(hdf5_filename, txt_filename, data, labels, name=None, descr=None, shuffle=False): | |
""" | |
Creates a HDF5 file containing given data and labels as HDF5 datasets with names 'data' and 'label'. | |
:param hdf5_filename: Filename of HDF5 file that is going to be created. | |
:type hdf5_filename: str | |
:param txt_filename: Filename of text file to write the HDF5 filename to. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
caffe_root = '/path/to/caffe/' | |
sys.path.insert(0, caffe_root + 'python') | |
import caffe.proto.caffe_pb2 as caffe_proto | |
def create_mean_file(filename, mean): | |
""" | |
Create a binaryproto file with a single blob containing the given pixel-wise mean. | |
Overwrites any existing file with the same name. |