Takes a file name, and loads a list of labels from it, one per line, and returns a vector of the strings. It pads with empty strings so the length of the result is a multiple of 16, because our model expects that.
| 100 | // returns a vector of the strings. It pads with empty strings so the length |
| 101 | // of the result is a multiple of 16, because our model expects that. |
| 102 | TfLiteStatus ReadLabelsFile(const string& file_name, |
| 103 | std::vector<string>* result, |
| 104 | size_t* found_label_count) { |
| 105 | std::ifstream file(file_name); |
| 106 | if (!file) { |
| 107 | LOG(FATAL) << "Labels file " << file_name << " not found\n"; |
| 108 | return kTfLiteError; |
| 109 | } |
| 110 | result->clear(); |
| 111 | string line; |
| 112 | while (std::getline(file, line)) { |
| 113 | result->push_back(line); |
| 114 | } |
| 115 | *found_label_count = result->size(); |
| 116 | const int padding = 16; |
| 117 | while (result->size() % padding) { |
| 118 | result->emplace_back(); |
| 119 | } |
| 120 | return kTfLiteOk; |
| 121 | } |
| 122 | |
| 123 | void PrintProfilingInfo(const profiling::ProfileEvent* e, uint32_t op_index, |
| 124 | TfLiteRegistration registration) { |
no test coverage detected