| 403 | } |
| 404 | |
| 405 | ValidationOutputAccessor::ValidationOutputAccessor(const std::string &image_list, |
| 406 | std::ostream &output_stream, |
| 407 | unsigned int start, |
| 408 | unsigned int end) |
| 409 | : _results(), _output_stream(output_stream), _offset(0), _positive_samples_top1(0), _positive_samples_top5(0) |
| 410 | { |
| 411 | ARM_COMPUTE_EXIT_ON_MSG(start > end, "Invalid validation range!"); |
| 412 | |
| 413 | std::ifstream ifs; |
| 414 | try |
| 415 | { |
| 416 | ifs.exceptions(std::ifstream::badbit); |
| 417 | ifs.open(image_list, std::ios::in | std::ios::binary); |
| 418 | |
| 419 | // Parse image correctly classified labels |
| 420 | unsigned int counter = 0; |
| 421 | for (std::string line; !std::getline(ifs, line).fail() && counter <= end; ++counter) |
| 422 | { |
| 423 | // Add label if within range |
| 424 | if (counter >= start) |
| 425 | { |
| 426 | std::stringstream linestream(line); |
| 427 | std::string image_name; |
| 428 | int result; |
| 429 | |
| 430 | linestream >> image_name >> result; |
| 431 | _results.emplace_back(result); |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | catch (const std::ifstream::failure &e) |
| 436 | { |
| 437 | ARM_COMPUTE_ERROR_VAR("Accessing %s: %s", image_list.c_str(), e.what()); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | void ValidationOutputAccessor::reset() |
| 442 | { |