Takes a file name, and loads a list of comma-separated box priors from it, one per line, and returns a vector of the values.
| 52 | // Takes a file name, and loads a list of comma-separated box priors from it, |
| 53 | // one per line, and returns a vector of the values. |
| 54 | Status ReadLocationsFile(const string& file_name, std::vector<float>* result, |
| 55 | size_t* found_label_count) { |
| 56 | std::ifstream file(file_name); |
| 57 | if (!file) { |
| 58 | return tensorflow::errors::NotFound("Labels file ", file_name, |
| 59 | " not found."); |
| 60 | } |
| 61 | result->clear(); |
| 62 | string line; |
| 63 | while (std::getline(file, line)) { |
| 64 | std::vector<string> string_tokens = tensorflow::str_util::Split(line, ','); |
| 65 | result->reserve(string_tokens.size()); |
| 66 | for (const string& string_token : string_tokens) { |
| 67 | float number; |
| 68 | CHECK(tensorflow::strings::safe_strtof(string_token, &number)); |
| 69 | result->push_back(number); |
| 70 | } |
| 71 | } |
| 72 | *found_label_count = result->size(); |
| 73 | return Status::OK(); |
| 74 | } |
| 75 | |
| 76 | // Given an image file name, read in the data, try to decode it as an image, |
| 77 | // resize it to the requested size, and then scale the values as desired. |
no test coverage detected