ArmNN
 20.02
ImagePreprocessor< TDataType > Class Template Reference

#include <ImagePreprocessor.hpp>

Public Types

enum  DataFormat { NHWC, NCHW }
 
using DataType = TDataType
 
using TTestCaseData = ClassifierTestCaseData< DataType >
 

Public Member Functions

 ImagePreprocessor (const std::string &binaryFileDirectory, unsigned int width, unsigned int height, const std::vector< ImageSet > &imageSet, float scale=255.0f, const std::array< float, 3 > mean={{0, 0, 0}}, const std::array< float, 3 > stddev={{1, 1, 1}}, DataFormat dataFormat=DataFormat::NHWC, unsigned int batchSize=1)
 
std::unique_ptr< TTestCaseDataGetTestCaseData (unsigned int testCaseId)
 
template<>
std::unique_ptr< ImagePreprocessor< float >::TTestCaseDataGetTestCaseData (unsigned int testCaseId)
 
template<>
std::unique_ptr< ImagePreprocessor< uint8_t >::TTestCaseDataGetTestCaseData (unsigned int testCaseId)
 

Detailed Description

template<typename TDataType>
class ImagePreprocessor< TDataType >

Definition at line 20 of file ImagePreprocessor.hpp.

Member Typedef Documentation

◆ DataType

using DataType = TDataType

Definition at line 23 of file ImagePreprocessor.hpp.

◆ TTestCaseData

Member Enumeration Documentation

◆ DataFormat

enum DataFormat
Enumerator
NHWC 
NCHW 

Definition at line 26 of file ImagePreprocessor.hpp.

Constructor & Destructor Documentation

◆ ImagePreprocessor()

ImagePreprocessor ( const std::string &  binaryFileDirectory,
unsigned int  width,
unsigned int  height,
const std::vector< ImageSet > &  imageSet,
float  scale = 255.0f,
const std::array< float, 3 >  mean = {{0, 0, 0}},
const std::array< float, 3 >  stddev = {{1, 1, 1}},
DataFormat  dataFormat = DataFormat::NHWC,
unsigned int  batchSize = 1 
)
inlineexplicit

Definition at line 32 of file ImagePreprocessor.hpp.

References ImagePreprocessor< TDataType >::GetTestCaseData().

37  {{0, 0, 0}},
38  const std::array<float, 3> stddev={{1, 1, 1}},
39  DataFormat dataFormat=DataFormat::NHWC,
40  unsigned int batchSize=1)
41  : m_BinaryDirectory(binaryFileDirectory)
42  , m_Height(height)
43  , m_Width(width)
44  , m_BatchSize(batchSize)
45  , m_Scale(scale)
46  , m_ImageSet(imageSet)
47  , m_Mean(mean)
48  , m_Stddev(stddev)
49  , m_DataFormat(dataFormat)
50  {
51  }

Member Function Documentation

◆ GetTestCaseData() [1/3]

std::unique_ptr<TTestCaseData> GetTestCaseData ( unsigned int  testCaseId)

◆ GetTestCaseData() [2/3]

std::unique_ptr< ImagePreprocessor< float >::TTestCaseData > GetTestCaseData ( unsigned int  testCaseId)

Definition at line 59 of file ImagePreprocessor.cpp.

60 {
61  std::vector<float> resized;
62  auto label = GetLabelAndResizedImageAsFloat(testCaseId, resized);
63  return std::make_unique<TTestCaseData>(label, std::move(resized));
64 }

◆ GetTestCaseData() [3/3]

std::unique_ptr< ImagePreprocessor< uint8_t >::TTestCaseData > GetTestCaseData ( unsigned int  testCaseId)

Definition at line 68 of file ImagePreprocessor.cpp.

69 {
70  std::vector<float> resized;
71  auto label = GetLabelAndResizedImageAsFloat(testCaseId, resized);
72 
73  size_t resizedSize = resized.size();
74  std::vector<uint8_t> quantized(resized.size());
75 
76  for (size_t i=0; i<resizedSize; ++i)
77  {
78  quantized[i] = static_cast<uint8_t>(resized[i]);
79  }
80 
81  return std::make_unique<TTestCaseData>(label, std::move(quantized));
82 }

The documentation for this class was generated from the following files: