@@ -162,6 +162,7 @@ DEFINE_int32(num, 3, "Number of scales for Yolo V3");
162
162
163
163
typedef std::chrono::high_resolution_clock Time;
164
164
// for Semantic Segmentation
165
+ DEFINE_bool (skip_arg_max, false , " Skip ArgMax post processing step" );
165
166
DEFINE_uint32 (sem_seg_classes, 12 , " Number of classes for semantic segmentation" );
166
167
DEFINE_double (sem_seg_threshold, 0.98 , " Threshold for 'semantic segmentation' mode" );
167
168
DEFINE_uint32 (sem_seg_ignore_label, std::numeric_limits<uint32_t >::max(), "The number of the label to be ignored");
@@ -1799,15 +1800,28 @@ bool testMeanIoU(const TensorMap& outputs, const TensorMap& references, const La
1799
1800
OPENVINO_ASSERT (outputs.size () == outputLayouts.size (),
1800
1801
" Mismatch between the number of model outputs and their corresponding layout values" );
1801
1802
1803
+ bool skipArgMax = FLAGS_skip_arg_max;
1802
1804
unsigned int classes = FLAGS_sem_seg_classes;
1803
1805
auto semSegThreshold = static_cast <float >(FLAGS_sem_seg_threshold);
1804
1806
1805
1807
std::vector<uint8_t > parsedReferences;
1806
1808
std::vector<uint8_t > parsedOutputs;
1807
1809
std::vector<std::pair<bool , float >> iou (classes, {false , 0 .0f });
1808
1810
1809
- utils::argMax_channels (references.begin ()->second , parsedReferences, outputLayouts.begin ()->second );
1810
- utils::argMax_channels (outputs.begin ()->second , parsedOutputs, outputLayouts.begin ()->second );
1811
+ if (skipArgMax) {
1812
+ const ov::Tensor referenceU8 = npu::utils::toPrecision (references.begin ()->second , ov::element::u8);
1813
+ const ov::Tensor outputU8 = npu::utils::toPrecision (outputs.begin ()->second , ov::element::u8);
1814
+
1815
+ const size_t C = referenceU8.get_shape ()[ov::layout::channels_idx (outputLayouts.begin ()->second )];
1816
+ const size_t H = referenceU8.get_shape ()[ov::layout::height_idx (outputLayouts.begin ()->second )];
1817
+ const size_t W = referenceU8.get_shape ()[ov::layout::width_idx (outputLayouts.begin ()->second )];
1818
+
1819
+ std::copy_n (referenceU8.data <uint8_t >(), C * H * W, std::back_insert_iterator (parsedReferences));
1820
+ std::copy_n (outputU8.data <uint8_t >(), C * H * W, std::back_insert_iterator (parsedOutputs));
1821
+ } else {
1822
+ utils::argMax_channels (references.begin ()->second , parsedReferences, outputLayouts.begin ()->second );
1823
+ utils::argMax_channels (outputs.begin ()->second , parsedOutputs, outputLayouts.begin ()->second );
1824
+ }
1811
1825
1812
1826
if (parsedReferences.size () != parsedOutputs.size ()) {
1813
1827
std::cout << " Reference size and output size are different" << std::endl;
0 commit comments