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.
| 70 | // returns a vector of the strings. It pads with empty strings so the length |
| 71 | // of the result is a multiple of 16, because our model expects that. |
| 72 | Status ReadLabelsFile(const string& file_name, std::vector<string>* result, |
| 73 | size_t* found_label_count) { |
| 74 | std::ifstream file(file_name); |
| 75 | if (!file) { |
| 76 | return tensorflow::errors::NotFound("Labels file ", file_name, |
| 77 | " not found."); |
| 78 | } |
| 79 | result->clear(); |
| 80 | string line; |
| 81 | while (std::getline(file, line)) { |
| 82 | result->push_back(line); |
| 83 | } |
| 84 | *found_label_count = result->size(); |
| 85 | const int padding = 16; |
| 86 | while (result->size() % padding) { |
| 87 | result->emplace_back(); |
| 88 | } |
| 89 | return Status::OK(); |
| 90 | } |
| 91 | |
| 92 | static Status ReadEntireFile(tensorflow::Env* env, const string& filename, |
| 93 | Tensor* output) { |
no test coverage detected