MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ReadLocationsFile

Function ReadLocationsFile

tensorflow/examples/multibox_detector/main.cc:54–74  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
54Status 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.

Callers 1

PrintTopDetectionsFunction · 0.85

Calls 7

NotFoundFunction · 0.85
safe_strtofFunction · 0.85
SplitFunction · 0.50
clearMethod · 0.45
reserveMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected