ArmNN
 21.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 56 of file ImagePreprocessor.cpp.

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

◆ GetTestCaseData() [3/3]

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

Definition at line 65 of file ImagePreprocessor.cpp.

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

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