ArmNN
 21.02
CaffePreprocessor Class Reference

#include <CaffePreprocessor.hpp>

Public Types

using DataType = float
 
using TTestCaseData = ClassifierTestCaseData< DataType >
 

Public Member Functions

 CaffePreprocessor (const std::string &binaryFileDirectory, unsigned int width=227, unsigned int height=227, const std::vector< ImageSet > &imageSet=std::vector< ImageSet >())
 
std::unique_ptr< TTestCaseDataGetTestCaseData (unsigned int testCaseId)
 

Detailed Description

Definition at line 18 of file CaffePreprocessor.hpp.

Member Typedef Documentation

◆ DataType

using DataType = float

Definition at line 21 of file CaffePreprocessor.hpp.

◆ TTestCaseData

Constructor & Destructor Documentation

◆ CaffePreprocessor()

CaffePreprocessor ( const std::string &  binaryFileDirectory,
unsigned int  width = 227,
unsigned int  height = 227,
const std::vector< ImageSet > &  imageSet = std::vector<ImageSet>() 
)
explicit

Definition at line 19 of file CaffePreprocessor.cpp.

21 : m_BinaryDirectory(binaryFileDirectory)
22 , m_Height(height)
23 , m_Width(width)
24 , m_ImageSet(imageSet.empty() ? g_DefaultImageSet : imageSet)
25 {
26 }
const std::vector< ImageSet > g_DefaultImageSet

Member Function Documentation

◆ GetTestCaseData()

std::unique_ptr< CaffePreprocessor::TTestCaseData > GetTestCaseData ( unsigned int  testCaseId)

Definition at line 28 of file CaffePreprocessor.cpp.

References Bgr, CHECK_LOCATION, GetImageDataInArmNnLayoutAsFloatsSubtractingMean(), armnn::numeric_cast(), and InferenceTestImage::Resize().

29 {
30  testCaseId = testCaseId % armnn::numeric_cast<unsigned int>(m_ImageSet.size());
31  const ImageSet& imageSet = m_ImageSet[testCaseId];
32  const std::string fullPath = m_BinaryDirectory + imageSet.first;
33 
34  InferenceTestImage image(fullPath.c_str());
35  image.Resize(m_Width, m_Height, CHECK_LOCATION());
36 
37  // The model expects image data in BGR format.
39  image, m_MeanBgr);
40 
41  // List of labels: https://gist.github.com/yrevar/942d3a0ac09ec9e5eb3a
42  const unsigned int label = imageSet.second;
43  return std::make_unique<TTestCaseData>(label, std::move(inputImageData));
44 }
std::pair< const std::string, unsigned int > ImageSet
Caffe requires BGR images, not normalized, mean adjusted and resized using smooth resize of STB libra...
std::vector< float > GetImageDataInArmNnLayoutAsFloatsSubtractingMean(ImageChannelLayout layout, const InferenceTestImage &image, const std::array< float, 3 > &mean)
#define CHECK_LOCATION()
Definition: Exceptions.hpp:197
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
Definition: NumericCast.hpp:35
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)

The documentation for this class was generated from the following files: