13 #include <boost/numeric/conversion/cast.hpp> 14 #include <boost/assert.hpp> 15 #include <boost/format.hpp> 21 template <
typename TDataType>
23 std::vector<float> & result)
25 testCaseId = testCaseId % boost::numeric_cast<
unsigned int>(m_ImageSet.size());
26 const ImageSet& imageSet = m_ImageSet[testCaseId];
27 const std::string fullPath = m_BinaryDirectory + imageSet.first;
37 m_Mean, m_Stddev, m_Scale);
40 for (
unsigned int i = 1; i < m_BatchSize; i++)
42 result.insert(result.end(), result.begin(), result.begin() + boost::numeric_cast<
int>(GetNumImageElements()));
45 if (m_DataFormat == DataFormat::NCHW)
49 std::vector<float> tempImage(result.size());
51 result.swap(tempImage);
54 return imageSet.second;
58 std::unique_ptr<ImagePreprocessor<float>::TTestCaseData>
61 std::vector<float> resized;
62 auto label = GetLabelAndResizedImageAsFloat(testCaseId, resized);
63 return std::make_unique<TTestCaseData>(label, std::move(resized));
67 std::unique_ptr<ImagePreprocessor<uint8_t>::TTestCaseData>
70 std::vector<float> resized;
71 auto label = GetLabelAndResizedImageAsFloat(testCaseId, resized);
73 size_t resizedSize = resized.size();
74 std::vector<uint8_t> quantized(resized.size());
76 for (
size_t i=0; i<resizedSize; ++i)
78 quantized[i] =
static_cast<uint8_t
>(resized[i]);
81 return std::make_unique<TTestCaseData>(label, std::move(quantized));
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
std::vector< float > Resize(unsigned int newWidth, unsigned int newHeight, const armnn::CheckLocation &location, const ResizingMethods meth=ResizingMethods::STB, const std::array< float, 3 > &mean={{0.0, 0.0, 0.0}}, const std::array< float, 3 > &stddev={{1.0, 1.0, 1.0}}, const float scale=255.0f)
const armnn::PermutationVector NHWCToArmNN
std::unique_ptr< TTestCaseData > GetTestCaseData(unsigned int testCaseId)
std::pair< const std::string, unsigned int > ImageSet
Caffe requires BGR images, not normalized, mean adjusted and resized using smooth resize of STB libra...