6 #include "../InferenceTestImage.hpp" 22 std::array<float, 3>
mean{ { 0.0, 0.0, 0.0 } };
23 std::array<float, 3>
stddev{ { 1.0, 1.0, 1.0 } };
43 normParams.
scale = 1.0;
44 normParams.
mean = { 0.0, 0.0, 0.0 };
45 normParams.
stddev = { 1.0, 1.0, 1.0 };
53 normParams.
scale = 127.5;
54 normParams.
mean = { 1.0, 1.0, 1.0 };
57 normParams.
mean = { 128.0, 128.0, 128.0 };
62 normParams.
mean = { 128.0, 128.0, 128.0 };
81 template <
typename ElemType>
83 unsigned int newWidth,
84 unsigned int newHeight,
86 unsigned int batchSize = 1,
92 unsigned int newWidth,
93 unsigned int newHeight,
95 unsigned int batchSize,
99 std::vector<float> imageData;
107 newHeight = testImage.GetHeight();
111 imageData = testImage.Resize(newWidth, newHeight,
CHECK_LOCATION(),
119 std::vector<float> tempImage(imageData.size());
120 armnnUtils::Permute(dstShape, NHWCToArmNN, imageData.data(), tempImage.data(),
sizeof(float));
121 imageData.swap(tempImage);
129 unsigned int newWidth,
130 unsigned int newHeight,
132 unsigned int batchSize,
136 std::vector<float> imageDataFloat =
139 std::vector<int> imageDataInt;
140 imageDataInt.reserve(imageDataFloat.size());
141 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataInt),
142 [](
float val) {
return static_cast<int>(val); });
149 unsigned int newWidth,
150 unsigned int newHeight,
152 unsigned int batchSize,
156 std::vector<float> imageDataFloat =
158 std::vector<uint8_t> imageDataQasymm8;
159 imageDataQasymm8.reserve(imageDataFloat.size());
161 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataQasymm8),
162 [](
float val) {
return static_cast<uint8_t
>(val); });
163 return imageDataQasymm8;
169 unsigned int newWidth,
170 unsigned int newHeight,
172 unsigned int batchSize,
176 std::vector<float> imageDataFloat =
178 std::vector<int8_t> imageDataQasymms8;
179 imageDataQasymms8.reserve(imageDataFloat.size());
181 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataQasymms8),
182 [](
float val) {
return static_cast<uint8_t
>(val); });
183 return imageDataQasymms8;
191 template <
typename ElemType>
194 std::copy(imageData.begin(), imageData.end(), std::ostream_iterator<ElemType>(imageTensorFile,
" "));
202 std::copy(imageData.begin(), imageData.end(), std::ostream_iterator<int>(imageTensorFile,
" "));
210 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
void WriteImageTensorImpl< int8_t >(const std::vector< int8_t > &imageData, std::ofstream &imageTensorFile)
std::vector< int8_t > PrepareImageTensor< int8_t >(const std::string &imagePath, unsigned int newWidth, unsigned int newHeight, const NormalizationParameters &normParams, unsigned int batchSize, const armnn::DataLayout &outputLayout)
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)