More explicit use of "Optional".
This commit is contained in:
25
src/main.cpp
25
src/main.cpp
@@ -1,11 +1,9 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <glog/logging.h>
|
||||
|
||||
#include "Options.hpp"
|
||||
#include "Simulator.hpp"
|
||||
#include "PNGDumper.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace fmri;
|
||||
@@ -14,15 +12,8 @@ int main(int argc, char *const argv[]) {
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
|
||||
Options options = Options::parse(argc, argv);
|
||||
vector<string> labels;
|
||||
if (!options.labels().empty()) {
|
||||
labels = read_vector<string>(options.labels());
|
||||
}
|
||||
|
||||
unique_ptr<PNGDumper> pngDumper;
|
||||
if (!options.imageDump().empty()) {
|
||||
pngDumper.reset(new PNGDumper(options.imageDump()));
|
||||
}
|
||||
auto labels = options.labels();
|
||||
auto dumper = options.imageDumper();
|
||||
|
||||
Simulator simulator(options.model(), options.weights(), options.means());
|
||||
|
||||
@@ -31,9 +22,9 @@ int main(int argc, char *const argv[]) {
|
||||
LOG(INFO) << "Result for " << image << ":" << endl;
|
||||
|
||||
const auto& resultRow = res[res.size() - 1];
|
||||
if (!labels.empty()) {
|
||||
if (labels) {
|
||||
vector<DType> weights(resultRow.data(), resultRow.data() + resultRow.numEntries());
|
||||
auto scores = combine(weights, labels);
|
||||
auto scores = combine(weights, *labels);
|
||||
sort(scores.begin(), scores.end(), greater<>());
|
||||
for (unsigned int i = 0; i < scores.size() && i < 5; ++i) {
|
||||
LOG(INFO) << scores[i].first << " " << scores[i].second << endl;
|
||||
@@ -42,9 +33,11 @@ int main(int argc, char *const argv[]) {
|
||||
LOG(INFO) << "Best result: " << *(resultRow.data(), resultRow.data() + resultRow.numEntries()) << endl;
|
||||
}
|
||||
|
||||
for (auto& layer : res) {
|
||||
pngDumper->dump(layer);
|
||||
}
|
||||
if (dumper) {
|
||||
for (const auto& layer : res) {
|
||||
dumper->dump(layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
google::ShutdownGoogleLogging();
|
||||
|
||||
Reference in New Issue
Block a user