MCPcopy Create free account
hub / github.com/Tencent/TNN / ImportDataSet

Function ImportDataSet

tools/quantization/quantize.cc:125–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123}
124
125int ImportDataSet(DataSet& dataset, std::string folder_path) {
126 dataset.file_list.clear();
127
128 DIR* dp;
129 struct dirent* dirp;
130 if ((dp = opendir(folder_path.c_str())) == NULL) {
131 printf("Can't open %s\n", folder_path.c_str());
132 return -1;
133 }
134 while ((dirp = readdir(dp)) != NULL) {
135 if (dirp->d_type == DT_REG) {
136 std::string file_name = dirp->d_name;
137 FileFormat format = NOTSUPPORT;
138 if (GetInputType(file_name, format)) {
139 char full_name[256 + 1];
140 snprintf(full_name, 256, "%s/%s", folder_path.c_str(), dirp->d_name);
141 dataset.file_list.push_back(std::make_pair(full_name, format));
142 printf("\timport: %s type: %d\n", dirp->d_name, format);
143 }
144 }
145 }
146 closedir(dp);
147
148 if (dataset.file_list.size() == 0) {
149 printf("no valid input file found!\n");
150 return -1;
151 }
152 printf("import total %lu files\n", dataset.file_list.size());
153 return 0;
154}
155
156bool CheckNumberString(std::string num_str) {
157 const char* num_char = num_str.c_str();

Callers 1

mainFunction · 0.85

Calls 3

GetInputTypeFunction · 0.70
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected