Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / validation_app / ClassificationProcessor.cpp
index 9c52c1e..7db4b32 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Intel Corporation
+// Copyright (C) 2018-2019 Intel Corporation
 // SPDX-License-Identifier: Apache-2.0
 //
 
@@ -33,11 +33,12 @@ ClassificationProcessor::ClassificationProcessor(const std::string& flags_m, con
 std::shared_ptr<Processor::InferenceMetrics> ClassificationProcessor::Process(bool stream_output) {
      slog::info << "Collecting labels" << slog::endl;
      ClassificationSetGenerator generator;
-     // try {
-     //     generator.readLabels(labelFileName);
-     // } catch (InferenceEngine::details::InferenceEngineException& ex) {
-     //     slog::warn << "Can't read labels file " << labelFileName << slog::endl;
-     // }
+     try {
+         generator.readLabels(labelFileName);
+     } catch (InferenceEngine::details::InferenceEngineException& ex) {
+         slog::warn << "Can't read labels file " << labelFileName << slog::endl;
+         slog::warn << "Error: " << ex.what() << slog::endl;
+     }
 
      auto validationMap = generator.getValidationMap(imagesPath);
      ImageDecoder decoder;
@@ -59,7 +60,7 @@ std::shared_ptr<Processor::InferenceMetrics> ClassificationProcessor::Process(bo
 
      auto iter = validationMap.begin();
      while (iter != validationMap.end()) {
-         int b = 0;
+         size_t b = 0;
          int filesWatched = 0;
          for (; b < batch && iter != validationMap.end(); b++, iter++, filesWatched++) {
              expected[b] = iter->first;
@@ -68,6 +69,7 @@ std::shared_ptr<Processor::InferenceMetrics> ClassificationProcessor::Process(bo
                  files[b] = iter->second;
              } catch (const InferenceEngineException& iex) {
                  slog::warn << "Can't read file " << iter->second << slog::endl;
+                 slog::warn << "Error: " << iex.what() << slog::endl;
                  // Could be some non-image file in directory
                  b--;
                  continue;
@@ -80,16 +82,16 @@ std::shared_ptr<Processor::InferenceMetrics> ClassificationProcessor::Process(bo
          auto firstOutputData = firstOutputBlob->buffer().as<PrecisionTrait<Precision::FP32>::value_type*>();
          InferenceEngine::TopResults(TOP_COUNT, *firstOutputBlob, results);
 
-         for (int i = 0; i < b; i++) {
+         for (size_t i = 0; i < b; i++) {
              int expc = expected[i];
              if (zeroBackground) expc++;
 
-             bool top1Scored = (results[0 + TOP_COUNT * i] == expc);
+             bool top1Scored = (static_cast<int>(results[0 + TOP_COUNT * i]) == expc);
              dumper << "\"" + files[i] + "\"" << top1Scored;
              if (top1Scored) im.top1Result++;
              for (int j = 0; j < TOP_COUNT; j++) {
                  unsigned classId = results[j + TOP_COUNT * i];
-                 if (classId == expc) {
+                 if (static_cast<int>(classId) == expc) {
                      im.topCountResult++;
                  }
                  dumper << classId << firstOutputData[classId + i * (firstOutputBlob->size() / batch)];