2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
5 #include "InferenceTestImage.hpp"
6 #include "CaffePreprocessor.hpp"
8 #include <armnn/utility/NumericCast.hpp>
14 const std::vector<ImageSet> g_DefaultImageSet =
19 CaffePreprocessor::CaffePreprocessor(const std::string& binaryFileDirectory, unsigned int width, unsigned int height,
20 const std::vector<ImageSet>& imageSet)
21 : m_BinaryDirectory(binaryFileDirectory)
24 , m_ImageSet(imageSet.empty() ? g_DefaultImageSet : imageSet)
28 std::unique_ptr<CaffePreprocessor::TTestCaseData> CaffePreprocessor::GetTestCaseData(unsigned int testCaseId)
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;
34 InferenceTestImage image(fullPath.c_str());
35 image.Resize(m_Width, m_Height, CHECK_LOCATION());
37 // The model expects image data in BGR format.
38 std::vector<float> inputImageData = GetImageDataInArmNnLayoutAsFloatsSubtractingMean(ImageChannelLayout::Bgr,
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));