Add a model loader/simulator that actually loads caffe models.
This commit is contained in:
@@ -1,15 +1,13 @@
|
|||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
|
|
||||||
# Compilation settings
|
# Compilation settings
|
||||||
CXXFLAGS=-Wall -Wextra -pedantic -std=c++17 -g -O2
|
CXXFLAGS=-Wall -Wextra -pedantic -std=c++17 -g -O2 -DCPU_ONLY
|
||||||
LDLIBS=
|
LDLIBS=-lcaffe -lboost_system -lglog
|
||||||
|
|
||||||
|
|
||||||
# Project artifacts
|
# Project artifacts
|
||||||
_EXE=fmri
|
_EXE=fmri
|
||||||
_OBJECTS=\
|
_OBJECTS=$(patsubst %.cpp, %.o, $(wildcard *.cpp))
|
||||||
main.o \
|
|
||||||
Options.o
|
|
||||||
|
|
||||||
all: fmri
|
all: fmri
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
18
src/Simulator.cpp
Normal file
18
src/Simulator.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Simulator::simulate(const string& image_file)
|
||||||
|
{
|
||||||
|
cerr << "This is not implemented yet." << endl;
|
||||||
|
}
|
||||||
22
src/Simulator.hpp
Normal file
22
src/Simulator.hpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <caffe/caffe.hpp>
|
||||||
|
|
||||||
|
namespace fmri {
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
class Simulator {
|
||||||
|
public:
|
||||||
|
typedef float DType;
|
||||||
|
|
||||||
|
Simulator(const string& model_file, const string& weights_file);
|
||||||
|
|
||||||
|
void simulate(const string& input_file);
|
||||||
|
|
||||||
|
private:
|
||||||
|
caffe::Net<DType> net;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,12 +1,21 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Options.hpp"
|
#include "Options.hpp"
|
||||||
|
#include "Simulator.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fmri;
|
using namespace fmri;
|
||||||
|
|
||||||
int main(int argc, char * const argv[])
|
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());
|
||||||
|
|
||||||
|
for (const auto& image : options.inputs()) {
|
||||||
|
simulator.simulate(image);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user