| 313 | } |
| 314 | |
| 315 | ValidationInputAccessor::ValidationInputAccessor(const std::string &image_list, |
| 316 | std::string images_path, |
| 317 | std::unique_ptr<IPreprocessor> preprocessor, |
| 318 | bool bgr, |
| 319 | unsigned int start, |
| 320 | unsigned int end, |
| 321 | std::ostream &output_stream) |
| 322 | : _path(std::move(images_path)), |
| 323 | _images(), |
| 324 | _preprocessor(std::move(preprocessor)), |
| 325 | _bgr(bgr), |
| 326 | _offset(0), |
| 327 | _output_stream(output_stream) |
| 328 | { |
| 329 | ARM_COMPUTE_EXIT_ON_MSG(start > end, "Invalid validation range!"); |
| 330 | |
| 331 | std::ifstream ifs; |
| 332 | try |
| 333 | { |
| 334 | ifs.exceptions(std::ifstream::badbit); |
| 335 | ifs.open(image_list, std::ios::in | std::ios::binary); |
| 336 | |
| 337 | // Parse image names |
| 338 | unsigned int counter = 0; |
| 339 | for (std::string line; !std::getline(ifs, line).fail() && counter <= end; ++counter) |
| 340 | { |
| 341 | // Add image to process if withing range |
| 342 | if (counter >= start) |
| 343 | { |
| 344 | std::stringstream linestream(line); |
| 345 | std::string image_name; |
| 346 | |
| 347 | linestream >> image_name; |
| 348 | _images.emplace_back(std::move(image_name)); |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | catch (const std::ifstream::failure &e) |
| 353 | { |
| 354 | ARM_COMPUTE_ERROR_VAR("Accessing %s: %s", image_list.c_str(), e.what()); |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | bool ValidationInputAccessor::access_tensor(arm_compute::ITensor &tensor) |
| 359 | { |