diff --git a/src/main.cpp b/src/main.cpp index 3443802..169d4d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,8 @@ +#include #include #include "Options.hpp" #include "Simulator.hpp" +#include "utils.hpp" using namespace std; using namespace fmri; @@ -9,11 +11,25 @@ int main(int argc, char *const argv[]) { ::google::InitGoogleLogging(argv[0]); Options options = Options::parse(argc, argv); + vector labels; + if (options.labels() != "") { + labels = read_vector(options.labels()); + } Simulator simulator(options.model(), options.weights(), options.means()); for (const auto &image : options.inputs()) { - simulator.simulate(image); + cout << "Result for " << image << ":" << endl; + auto res = simulator.simulate(image); + if (!labels.empty()) { + for (unsigned int i = 0; i < res.size(); ++i) { + cout << res[i] << " " << labels[i] << endl; + } + } else { + cout << "Best result: " << *(max_element(res.begin(), res.end())) << endl; + } + + cout << endl; } ::google::ShutdownGoogleLogging(); diff --git a/src/utils.hpp b/src/utils.hpp new file mode 100644 index 0000000..e7b43df --- /dev/null +++ b/src/utils.hpp @@ -0,0 +1,43 @@ +#pragma once + +#include +#include +#include +#include + +namespace fmri +{ + + template + inline std::vector read_vector(const std::string& filename) + { + std::ifstream input(filename); + assert(input.good()); + + T t; + std::vector res; + + while (input >> t) { + res.push_back(t); + } + + return res; + } + + template<> + inline std::vector read_vector(const std::string& filename) + { + std::ifstream input(filename); + assert(input.good()); + + std::string v; + std::vector res; + + while (getline(input, v)) { + res.push_back(v); + } + + return res; + } + +} \ No newline at end of file