6 #include "../InferenceTestImage.hpp" 21 std::array<float, 3>
mean{ { 0.0, 0.0, 0.0 } };
22 std::array<float, 3>
stddev{ { 1.0, 1.0, 1.0 } };
42 normParams.
scale = 1.0;
43 normParams.
mean = { 0.0, 0.0, 0.0 };
44 normParams.
stddev = { 1.0, 1.0, 1.0 };
52 normParams.
scale = 127.5;
53 normParams.
mean = { 1.0, 1.0, 1.0 };
56 normParams.
mean = { 128.0, 128.0, 128.0 };
76 template <
typename ElemType>
78 unsigned int newWidth,
79 unsigned int newHeight,
81 unsigned int batchSize = 1,
87 unsigned int newWidth,
88 unsigned int newHeight,
90 unsigned int batchSize,
94 std::vector<float> imageData;
102 newHeight = testImage.GetHeight();
106 imageData = testImage.Resize(newWidth, newHeight,
CHECK_LOCATION(),
114 std::vector<float> tempImage(imageData.size());
115 armnnUtils::Permute(dstShape, NHWCToArmNN, imageData.data(), tempImage.data(),
sizeof(float));
116 imageData.swap(tempImage);
124 unsigned int newWidth,
125 unsigned int newHeight,
127 unsigned int batchSize,
131 std::vector<float> imageDataFloat =
134 std::vector<int> imageDataInt;
135 imageDataInt.reserve(imageDataFloat.size());
136 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataInt),
137 [](
float val) {
return static_cast<int>(val); });
144 unsigned int newWidth,
145 unsigned int newHeight,
147 unsigned int batchSize,
151 std::vector<float> imageDataFloat =
153 std::vector<uint8_t> imageDataQasymm8;
154 imageDataQasymm8.reserve(imageDataFloat.size());
156 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataQasymm8),
157 [](
float val) {
return static_cast<uint8_t
>(val); });
158 return imageDataQasymm8;
166 template <
typename ElemType>
169 std::copy(imageData.begin(), imageData.end(), std::ostream_iterator<ElemType>(imageTensorFile,
" "));
177 std::copy(imageData.begin(), imageData.end(), std::ostream_iterator<int>(imageTensorFile,
" "));
std::array< float, 3 > stddev
NormalizationParameters GetNormalizationParameters(const SupportedFrontend &modelFormat, const armnn::DataType &outputType)
Get normalization parameters.
std::vector< ElemType > PrepareImageTensor(const std::string &imagePath, unsigned int newWidth, unsigned int newHeight, const NormalizationParameters &normParams, unsigned int batchSize=1, const armnn::DataLayout &outputLayout=armnn::DataLayout::NHWC)
Prepare raw image tensor data by loading the image from imagePath and preprocessing it...
void WriteImageTensorImpl(const std::vector< ElemType > &imageData, std::ofstream &imageTensorFile)
Write image tensor to ofstream.
std::vector< uint8_t > PrepareImageTensor< uint8_t >(const std::string &imagePath, unsigned int newWidth, unsigned int newHeight, const NormalizationParameters &normParams, unsigned int batchSize, const armnn::DataLayout &outputLayout)
const armnn::PermutationVector NHWCToArmNN
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
unsigned int GetWidth() const
void WriteImageTensorImpl< uint8_t >(const std::vector< uint8_t > &imageData, std::ofstream &imageTensorFile)
std::vector< int > PrepareImageTensor< int >(const std::string &imagePath, unsigned int newWidth, unsigned int newHeight, const NormalizationParameters &normParams, unsigned int batchSize, const armnn::DataLayout &outputLayout)
std::array< float, 3 > mean
std::vector< float > PrepareImageTensor< float >(const std::string &imagePath, unsigned int newWidth, unsigned int newHeight, const NormalizationParameters &normParams, unsigned int batchSize, const armnn::DataLayout &outputLayout)