diff --git a/src/Options.cpp b/src/Options.cpp index 040b488..5473ad3 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -1,18 +1,16 @@ #include #include #include -#include #include #include "Options.hpp" using namespace fmri; using namespace std; -static void show_help(const char* progname, int exitcode) -{ - cerr << "Usage: " << progname << " -m MODEL -w WEIGHTS INPUTS..." << endl - << endl - << R"END( +static void show_help(const char *progname, int exitcode) { + cerr << "Usage: " << progname << " -m MODEL -w WEIGHTS INPUTS..." << endl + << endl + << R"END( Simulate the specified network on the specified inputs. Options: @@ -21,88 +19,82 @@ Options: -w (required) the trained weights )END" << endl; - exit(exitcode); + exit(exitcode); } -static void check_file(const char * filename) -{ - if (access(filename, R_OK) != 0) { - perror(filename); - exit(1); - } +static void check_file(const char *filename) { + if (access(filename, R_OK) != 0) { + perror(filename); + exit(1); + } } -Options Options::parse(const int argc, char * const argv[]) -{ - string model; - string weights; +Options Options::parse(const int argc, char *const argv[]) { + string model; + string weights; - char c; + char c; - while ((c = getopt(argc, argv, "hm:w:")) != -1) { - switch (c) { - case 'h': - show_help(argv[0], 0); - break; + while ((c = getopt(argc, argv, "hm:w:")) != -1) { + switch (c) { + case 'h': + show_help(argv[0], 0); + break; - case 'w': - check_file(optarg); - weights = optarg; - break; + case 'w': + check_file(optarg); + weights = optarg; + break; - case 'm': - check_file(optarg); - model = optarg; - break; + case 'm': + check_file(optarg); + model = optarg; + break; - case '?': - show_help(argv[0], 1); - break; + case '?': + show_help(argv[0], 1); + break; - default: - abort(); - } - } + default: + abort(); + } + } - if (weights.empty()) { - cerr << "Weights file is required!" << endl; - show_help(argv[0], 1); - } + if (weights.empty()) { + cerr << "Weights file is required!" << endl; + show_help(argv[0], 1); + } - if (model.empty()) { - cerr << "Model file is required!" << endl; - show_help(argv[0], 1); - } + if (model.empty()) { + cerr << "Model file is required!" << endl; + show_help(argv[0], 1); + } - for_each(argv + optind, argv + argc, check_file); + for_each(argv + optind, argv + argc, check_file); - vector inputs(argv + optind, argv + argc); - if (inputs.empty()) { - cerr << "No inputs specified" << endl; - show_help(argv[0], 1); - } + vector inputs(argv + optind, argv + argc); + if (inputs.empty()) { + cerr << "No inputs specified" << endl; + show_help(argv[0], 1); + } - return Options(move(model), move(weights), move(inputs)); + return Options(move(model), move(weights), move(inputs)); } -Options::Options(string&& model, string&& weights, vector&& inputs) noexcept: - modelPath(move(model)), - weightsPath(move(weights)), - inputPaths(move(inputs)) -{ +Options::Options(string &&model, string &&weights, vector &&inputs) noexcept: + modelPath(move(model)), + weightsPath(move(weights)), + inputPaths(move(inputs)) { } -const string& Options::model() const -{ - return modelPath; +const string &Options::model() const { + return modelPath; } -const string& Options::weights() const -{ - return weightsPath; +const string &Options::weights() const { + return weightsPath; } -const vector& Options::inputs() const -{ - return inputPaths; +const vector &Options::inputs() const { + return inputPaths; } diff --git a/src/Options.hpp b/src/Options.hpp index f32a636..0c2b2ac 100644 --- a/src/Options.hpp +++ b/src/Options.hpp @@ -5,23 +5,24 @@ namespace fmri { - using std::vector; - using std::string; + using std::vector; + using std::string; - class Options - { - public: - static Options parse(const int argc, char * const argv[]); + class Options { + public: + static Options parse(const int argc, char *const argv[]); - const string& model() const; - const string& weights() const; - const vector& inputs() const; + const string &model() const; - private: - const string modelPath; - const string weightsPath; - const vector inputPaths; + const string &weights() const; - Options(string&&, string&&, vector&&) noexcept; - }; + const vector &inputs() const; + + private: + const string modelPath; + const string weightsPath; + const vector inputPaths; + + Options(string &&, string &&, vector &&) noexcept; + }; } diff --git a/src/Simulator.cpp b/src/Simulator.cpp index e06ed45..4919ea2 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -1,18 +1,15 @@ #include -#include #include "Simulator.hpp" using namespace caffe; using namespace std; using namespace fmri; -Simulator::Simulator(const string& model_file, const string& weights_file) : - net(model_file, TEST) -{ - net.CopyTrainedLayersFrom(weights_file); +Simulator::Simulator(const string &model_file, const string &weights_file) : + net(model_file, TEST) { + net.CopyTrainedLayersFrom(weights_file); } -void Simulator::simulate(const string& image_file) -{ - cerr << "This is not implemented yet." << endl; +void Simulator::simulate(const string &image_file) { + cerr << "This is not implemented yet." << endl; } diff --git a/src/Simulator.hpp b/src/Simulator.hpp index 7587d3e..262b450 100644 --- a/src/Simulator.hpp +++ b/src/Simulator.hpp @@ -6,17 +6,17 @@ #include namespace fmri { - using std::string; + using std::string; - class Simulator { - public: - typedef float DType; + class Simulator { + public: + typedef float DType; - Simulator(const string& model_file, const string& weights_file); + Simulator(const string &model_file, const string &weights_file); - void simulate(const string& input_file); + void simulate(const string &input_file); - private: - caffe::Net net; - }; + private: + caffe::Net net; + }; } diff --git a/src/main.cpp b/src/main.cpp index b829569..15487d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,17 +5,16 @@ using namespace std; using namespace fmri; -int main(int argc, char * const argv[]) -{ - ::google::InitGoogleLogging(argv[0]); +int main(int argc, char *const argv[]) { + ::google::InitGoogleLogging(argv[0]); - Options options = Options::parse(argc, argv); + Options options = Options::parse(argc, argv); - Simulator simulator(options.model(), options.weights()); + Simulator simulator(options.model(), options.weights()); - for (const auto& image : options.inputs()) { - simulator.simulate(image); - } + for (const auto &image : options.inputs()) { + simulator.simulate(image); + } - return 0; + return 0; }