20.02
|
#include "../InferenceTestImage.hpp"
#include <armnn/TypesUtils.hpp>
#include <armnnUtils/Permute.hpp>
#include <algorithm>
#include <fstream>
#include <iterator>
#include <string>
Go to the source code of this file.
Classes | |
struct | NormalizationParameters |
Enumerations | |
enum | SupportedFrontend { Caffe = 0, TensorFlow = 1, TFLite = 2 } |
Functions | |
NormalizationParameters | GetNormalizationParameters (const SupportedFrontend &modelFormat, const armnn::DataType &outputType) |
Get normalization parameters. More... | |
template<typename ElemType > | |
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. More... | |
template<> | |
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) |
template<> | |
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) |
template<> | |
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) |
template<typename ElemType > | |
void | WriteImageTensorImpl (const std::vector< ElemType > &imageData, std::ofstream &imageTensorFile) |
Write image tensor to ofstream. More... | |
template<> | |
void | WriteImageTensorImpl< uint8_t > (const std::vector< uint8_t > &imageData, std::ofstream &imageTensorFile) |
|
strong |
NormalizationParameters GetNormalizationParameters | ( | const SupportedFrontend & | modelFormat, |
const armnn::DataType & | outputType | ||
) |
Get normalization parameters.
Note that different flavours of models and different model data types have different normalization methods. This tool currently only supports Caffe, TF and TFLite models
[in] | modelFormat | One of the supported frontends |
[in] | outputType | Output type of the image tensor, also the type of the intended model |
Definition at line 39 of file ImageTensorGenerator.hpp.
References Caffe, armnn::Float32, NormalizationParameters::mean, armnn::NHWC, PrepareImageTensor(), armnn::QAsymmU8, NormalizationParameters::scale, armnn::Signed32, NormalizationParameters::stddev, TensorFlow, and TFLite.
Referenced by main().
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.
[in] | imagePath | Path to the image file |
[in] | newWidth | The new width of the output image tensor |
[in] | newHeight | The new height of the output image tensor |
[in] | normParams | Normalization parameters for the normalization of the image |
[in] | batchSize | Batch size |
[in] | outputLayout | Data layout of the output image tensor |
Referenced by GetNormalizationParameters().
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 | ||
) |
Definition at line 91 of file ImageTensorGenerator.hpp.
References InferenceTestImage::BilinearAndNormalized, CHECK_LOCATION, InferenceTestImage::GetWidth(), NormalizationParameters::mean, armnn::NCHW, armnnUtils::NHWCToArmNN, armnnUtils::Permute(), NormalizationParameters::scale, and NormalizationParameters::stddev.
Referenced by main(), PrepareImageTensor< int >(), and PrepareImageTensor< uint8_t >().
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 | ||
) |
Definition at line 128 of file ImageTensorGenerator.hpp.
References PrepareImageTensor< float >().
Referenced by main().
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 | ||
) |
Definition at line 148 of file ImageTensorGenerator.hpp.
References PrepareImageTensor< float >().
Referenced by main().
void WriteImageTensorImpl | ( | const std::vector< ElemType > & | imageData, |
std::ofstream & | imageTensorFile | ||
) |
Write image tensor to ofstream.
[in] | imageData | Image tensor data |
[in] | imageTensorFile | Output filestream (ofstream) to which the image tensor data is written |
Definition at line 172 of file ImageTensorGenerator.hpp.
Referenced by main().
void WriteImageTensorImpl< uint8_t > | ( | const std::vector< uint8_t > & | imageData, |
std::ofstream & | imageTensorFile | ||
) |
Definition at line 180 of file ImageTensorGenerator.hpp.