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 };
61 normParams.
mean = { 128.0, 128.0, 128.0 };
80 template <
typename ElemType>
82 unsigned int newWidth,
83 unsigned int newHeight,
85 unsigned int batchSize = 1,
91 unsigned int newWidth,
92 unsigned int newHeight,
94 unsigned int batchSize,
98 std::vector<float> imageData;
106 newHeight = testImage.GetHeight();
110 imageData = testImage.Resize(newWidth, newHeight,
CHECK_LOCATION(),
118 std::vector<float> tempImage(imageData.size());
119 armnnUtils::Permute(dstShape, NHWCToArmNN, imageData.data(), tempImage.data(),
sizeof(float));
120 imageData.swap(tempImage);
128 unsigned int newWidth,
129 unsigned int newHeight,
131 unsigned int batchSize,
135 std::vector<float> imageDataFloat =
138 std::vector<int> imageDataInt;
139 imageDataInt.reserve(imageDataFloat.size());
140 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataInt),
141 [](
float val) {
return static_cast<int>(val); });
148 unsigned int newWidth,
149 unsigned int newHeight,
151 unsigned int batchSize,
155 std::vector<float> imageDataFloat =
157 std::vector<uint8_t> imageDataQasymm8;
158 imageDataQasymm8.reserve(imageDataFloat.size());
160 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataQasymm8),
161 [](
float val) {
return static_cast<uint8_t
>(val); });
162 return imageDataQasymm8;
168 unsigned int newWidth,
169 unsigned int newHeight,
171 unsigned int batchSize,
175 std::vector<float> imageDataFloat =
177 std::vector<int8_t> imageDataQasymms8;
178 imageDataQasymms8.reserve(imageDataFloat.size());
180 std::transform(imageDataFloat.begin(), imageDataFloat.end(), std::back_inserter(imageDataQasymms8),
181 [](
float val) {
return static_cast<uint8_t
>(val); });
182 return imageDataQasymms8;
190 template <
typename ElemType>
193 std::copy(imageData.begin(), imageData.end(), std::ostream_iterator<ElemType>(imageTensorFile,
" "));
201 std::copy(imageData.begin(), imageData.end(), std::ostream_iterator<int>(imageTensorFile,
" "));
209 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)