-
Notifications
You must be signed in to change notification settings - Fork 930
Description
Description:
When running tensorflow/lite/micro/tools/generate_cc_arrays.py
, if the input file is specified as an absolute path, the output files are not created in the directory defined by the args.output
argument. Instead, they are created alongside the input file, regardless of the output directory requested.
This is because of the following line (line 145):
output_base_fname = os.path.join(args.output, os.path.splitext(input_file)[0])
If input_file
is an absolute path, os.path.join
ignores args.output
and uses the absolute part only.
Example:
args.output = "/tmp/outputs"
input_file = "/home/user/data/model.tflite"
Actual output:
/home/user/data/model_model_data.cc
/home/user/data/model_model_data.h
Expected output:
/tmp/outputs/model_model_data.cc
/tmp/outputs/model_model_data.h
Suggested Solution:
To ensure output files are always placed in the specified output directory, even when input_file
is an absolute path, use only the base filename of input_file
when constructing output_base_fname
. For example, replace line 145 with:
output_base_fname = os.path.join(args.output, os.path.splitext(os.path.basename(input_file))[0])
This will generate the output files in the correct directory, regardless of whether the input file path is absolute or relative.
References: