#include "../InferenceTest.hpp"
#include "../ImagePreprocessor.hpp"
#include "armnnTfLiteParser/ITfLiteParser.hpp"
#include "boost/program_options.hpp"
#include <fstream>
Go to the source code of this file.
◆ GetLabelsFilenameFromOptions()
std::string GetLabelsFilenameFromOptions |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 62 of file TfLiteMobilenetQuantized-Armnn.cpp.
Referenced by main().
64 namespace po = boost::program_options;
65 po::options_description desc(
"Validation Options");
68 (
"labels", po::value<std::string>(&fn),
"Filename of a text file where in each line contains an image " 69 "filename and the correct label the network should predict when fed that image");
71 po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
72 po::store(parsed, vm);
73 if (vm.count(
"labels"))
75 fn = vm[
"labels"].as<std::string>();
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 81 of file TfLiteMobilenetQuantized-Armnn.cpp.
References armnn::test::ClassifierInferenceTestMain(), GetLabelsFilenameFromOptions(), and ParseDataset().
83 int retVal = EXIT_FAILURE;
88 std::vector<ImageSet> imageSet =
ParseDataset(labels_file);
89 std::vector<unsigned int> indices(imageSet.size());
90 std::generate(indices.begin(), indices.end(), [n = 0] ()
mutable {
return n++; });
103 "mobilenet_v1_1.0_224_quant.tflite",
106 "MobilenetV1/Predictions/Reshape_1",
108 [&imageSet](
const char* dataDir,
const ModelType &) {
120 catch (
const std::exception& e)
125 std::cerr <<
"WARNING: " << *argv <<
": An error has occurred when running " 126 "the classifier inference tests: " << e.what() << std::endl;
std::vector< ImageSet > ParseDataset(const std::string &filename)
std::string GetLabelsFilenameFromOptions(int argc, char *argv[])
int ClassifierInferenceTestMain(int argc, char *argv[], const char *modelFilename, bool isModelBinary, const char *inputBindingName, const char *outputBindingName, const std::vector< unsigned int > &defaultTestCaseIds, TConstructDatabaseCallable constructDatabase, const armnn::TensorShape *inputTensorShape=nullptr)
◆ ParseDataset()
std::vector<ImageSet> ParseDataset |
( |
const std::string & |
filename | ) |
|
Definition at line 14 of file TfLiteMobilenetQuantized-Armnn.cpp.
Referenced by main().
16 std::ifstream read(filename);
17 std::vector<ImageSet> imageSet;
21 for (std::string line; std::getline(read, line);)
23 stringstream ss(line);
24 std::string image_name;
26 getline(ss, image_name,
' ');
27 getline(ss, label,
' ');
28 imageSet.push_back(
ImageSet(image_name, std::stoi(label)));
34 imageSet.push_back(
ImageSet(
"Dog.jpg", 209));
42 imageSet.push_back(
ImageSet(
"Cat.jpg", 283));
50 imageSet.push_back(
ImageSet(
"shark.jpg", 3));
std::pair< const std::string, unsigned int > ImageSet
Caffe requires BGR images, not normalized, mean adjusted and resized using smooth resize of STB libra...