Update generate_cc_arrays to take any filetype - If the filetype isn't a special one that the script knows, simply process the data into an array of bytes instead of giving up. Change-Id: I531d8cd8f9f1692570d0cf51e6eace2f83ef2e92
diff --git a/tensorflow/lite/micro/tools/generate_cc_arrays.py b/tensorflow/lite/micro/tools/generate_cc_arrays.py index 4d1e54c..759db56 100644 --- a/tensorflow/lite/micro/tools/generate_cc_arrays.py +++ b/tensorflow/lite/micro/tools/generate_cc_arrays.py
@@ -94,9 +94,12 @@ data_1d = data.flatten() out_string = ','.join([str(x) for x in data_1d]) return [len(data_1d), out_string] - else: - raise ValueError('input file must be .tflite, .bmp, .wav or .csv') + with open(input_fname, 'rb') as input_file: + buffer = input_file.read() + size = len(buffer) + out_string = bytes_to_hexstring(buffer) + return [size, out_string] def get_array_name(input_fname): @@ -119,6 +122,8 @@ return [base_array_name + '_test_data', 'float'] elif input_fname.endswith('npy'): return [base_array_name + '_test_data', 'float'] + else: + return [base_array_name, 'unsigned char'] def main():