Commit e48589eb authored by Joseph Larralde's avatar Joseph Larralde
Browse files

minor updates

parent 0f3b33d6
......@@ -81,25 +81,27 @@ bool xmmTool<SingleClassModel, Model>::train(const rapidmix::trainingData& newTr
template <class SingleClassModel, class Model>
Json::Value xmmTool<SingleClassModel, Model>::toJSON(/*std::string modelType*/) {
Json::Value root;
Json::Value metadata;
Json::Value modelSet;
metadata["creator"] = "Rapid API C++";
metadata["version"] = "v0.1.1"; //TODO: This should be a macro someplace
metadata["family"] = "xmm";
root["metadata"] = metadata;
root["docType"] = "rapid-mix:ml-model";
root["docVersion"] = RAPIDMIX_JSON_DOC_VERSION;
modelSet.append(model.toJson());
root["modelSet"] = modelSet;
Json::Value target;
target["name"] = "xmm";
target["version"] = "v1.0.0";
root["target"] = target;
root["payload"] = model.toJson();
return root;
}
template <class SingleClassModel, class Model>
bool xmmTool<SingleClassModel, Model>::fromJSON(Json::Value &jm) {
if (jm["metadata"]["family"].asString().compare("xmm") == 0 &&
jm["modelSet"].size() > 0) {
model.fromJson(jm["modelSet"][0]);
if (jm["docType"].asString().compare("rapid-mix:ml-model") == 0 &&
jm["target"]["name"].asString().compare("xmm") == 0 &&
jm["payload"].size() > 0) {
model.fromJson(jm["payload"]);
model.reset();
return true;
}
......
......@@ -107,7 +107,7 @@ int main() {
std::vector<float> f({ 1, 2, 3 });
spHost.frames(0, 1, &f[0], 1, 1);
}
std::cout << "pipo passed" << std::endl;
std::cout << "pipo passed." << std::endl;
/////////////////////////////////////Test rapidStream signal processing
......
......@@ -17,6 +17,22 @@
#define MAX_PATH_SIZE 256
void doSomething(double time, double weight, PiPoValue *values, unsigned int size)
{
std::cout << time << std::endl;
}
class Stuff {
public:
Stuff() {}
~Stuff() {}
void doSomething(double time, double weight, PiPoValue *values, unsigned int size)
{
std::cout << time << std::endl;
}
};
//=============================== ONSEG TEST =================================//
SCENARIO("Test rapidPiPoHost", "[signalProcessing]")
......@@ -24,6 +40,7 @@ SCENARIO("Test rapidPiPoHost", "[signalProcessing]")
GIVEN("A rapidPiPoHost class with a rapidPiPo chain and an audio file")
{
maxiSample buffer;
Stuff stuff;
// in XCode this gives the path to DerivedData folder
// char pathStrBuf[MAX_PATH_SIZE];
......@@ -39,7 +56,12 @@ SCENARIO("Test rapidPiPoHost", "[signalProcessing]")
//====================================================================//
// instantiate PiPo related classes here :
rapidmix::signalProcessingHost host; // -> this class is located in rapidPiPoTools
rapidmix::signalProcessingHost host;
// host.setFrameCallback(doSomething);
// host.setFrameCallback(stuff.doSomething);
// host.setFrameCallback(dynamic_cast<frameCallback>(std::bind(&Stuff::doSomething, stuff)));
// host.setFrameCallback(dynamic_cast<frameCallback>(Stuff::* doSomething));
// if we want to add some custom PiPos to our collection :
// #include "myCustomPiPo.h"
......@@ -118,7 +140,7 @@ SCENARIO("Test rapidPiPoHost", "[signalProcessing]")
sa.domain = 0;
sa.maxFrames = 1;
host.setInputStreamAttributes(sa);
host.setInputSignalAttributes(sa);
float value;
for (unsigned int i = 0; i < buffer.length; ++i) {
......
//
// test_rapidXmmTools.cpp
// Unit tests for rapidXmmTools
//
#ifndef CATCH_CONFIG_MAIN
#define CATCH_CONFIG_MAIN
#endif
......@@ -291,6 +286,8 @@ SCENARIO("Test HMR", "[machineLearning]")
std::string filepath = "/var/tmp/modelSetDescription";
myHmr.writeJSON(filepath);
myHmr.reset();
WHEN("HMR model processes the phrase it was trained with")
{
THEN("check its regression output is the same as the output example")
......@@ -324,6 +321,9 @@ SCENARIO("Test HMR", "[machineLearning]")
for (int i = 0; i < myXmmPhrase.size(); ++i) {
myHmr.reset();
myHmrFromFile.reset();
THEN("compare results of original and deserialized models")
{
int cnt = 0;
......@@ -357,6 +357,9 @@ SCENARIO("Test HMR", "[machineLearning]")
for (int i = 0; i < myXmmPhrase.size(); ++i) {
myHmr.reset();
myHmrFromString.reset();
THEN("compare results of original and deserialized models")
{
int cnt = 0;
......
#ifndef CATCH_CONFIG_MAIN
#define CATCH_CONFIG_MAIN
#endif
#include "catch.hpp"
#include "machineLearning.h"
//============================= TRAINING DATA ================================//
SCENARIO("Test training sets managements", "[machineLearning]")
{
GIVEN("A training set we fill in a variety of ways")
{
rapidmix::trainingData set;
set.createNewPhrase("test_label_01");
std::vector <std::pair <std::vector<double>, std::vector<double>>> phrase = {
{ { 0.0, 0.0 }, { 9.0 } },
{ { 1.0, 0.0 }, { 8.0 } },
{ { 2.0, 0.0 }, { 7.0 } },
{ { 3.0, 0.0 }, { 6.0 } },
{ { 4.0, 0.0 }, { 5.0 } },
{ { 5.0, 0.0 }, { 4.0 } },
{ { 6.0, 0.0 }, { 3.0 } },
{ { 7.0, 0.0 }, { 2.0 } },
{ { 8.0, 0.0 }, { 1.0 } },
{ { 9.0, 0.0 }, { 0.0 } }
};
for (int i = 0; i < phrase.size(); ++i) {
set.addElement(phrase[i].first, phrase[i].second);
}
WHEN("We serialize / deserialize a training set")
{
std::string js = set.getJSON();
std::cout << js << std::endl;
THEN("It should stay the same")
{
}
}
}
}
......@@ -38,6 +38,9 @@
311BA31E1EDC7ADE00244DAC /* maximilian.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5A1F1ED8450C00E9FAFA /* maximilian.cpp */; };
311BA3211EDC7B2400244DAC /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 311BA3201EDC7B2400244DAC /* Accelerate.framework */; };
311BA3251EDCE80B00244DAC /* jsoncpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5E081ED8450E00E9FAFA /* jsoncpp.cpp */; };
312C61BD1FE95A680085E283 /* trainingData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5EC01ED8459300E9FAFA /* trainingData.cpp */; };
312C61CD1FE95A680085E283 /* jsoncpp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE2C5E081ED8450E00E9FAFA /* jsoncpp.cpp */; };
312C61D41FE95A8F0085E283 /* test_trainingData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 312C61B71FE958CB0085E283 /* test_trainingData.cpp */; };
319C94A11FC5BFA80055BE40 /* PiPoHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C93FD1FC49BAA0055BE40 /* PiPoHost.cpp */; };
319C94A21FC5C0C10055BE40 /* PiPoCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C947C1FC49D490055BE40 /* PiPoCollection.cpp */; };
319C94A31FC5C0DE0055BE40 /* BayesianFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 319C93ED1FC49B5C0055BE40 /* BayesianFilter.cpp */; };
......@@ -148,6 +151,15 @@
);
runOnlyForDeploymentPostprocessing = 1;
};
312C61CF1FE95A680085E283 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
31D7B7281E6B048100917757 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 12;
......@@ -216,6 +228,8 @@
311BA2FC1EDC6F1900244DAC /* xmm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = xmm.h; path = xmm/src/xmm.h; sourceTree = "<group>"; };
311BA3201EDC7B2400244DAC /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = System/Library/Frameworks/Accelerate.framework; sourceTree = SDKROOT; };
311BA3231EDC7BA400244DAC /* DnB-loop-175BPM.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = "DnB-loop-175BPM.wav"; path = "data/DnB-loop-175BPM.wav"; sourceTree = "<group>"; };
312C61B71FE958CB0085E283 /* test_trainingData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_trainingData.cpp; sourceTree = "<group>"; };
312C61D31FE95A680085E283 /* test_trainingData */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = test_trainingData; sourceTree = BUILT_PRODUCTS_DIR; };
318E7A361FD748D900FEEB7E /* pipo.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; name = pipo.json; path = data/pipo.json; sourceTree = "<group>"; };
319C93ED1FC49B5C0055BE40 /* BayesianFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BayesianFilter.cpp; path = pipo/modules/bayesfilter/src/BayesianFilter.cpp; sourceTree = "<group>"; };
319C93EE1FC49B5C0055BE40 /* BayesianFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BayesianFilter.h; path = pipo/modules/bayesfilter/src/BayesianFilter.h; sourceTree = "<group>"; };
......@@ -448,6 +462,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
312C61CE1FE95A680085E283 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
31D7B7271E6B048100917757 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
......@@ -1046,6 +1067,7 @@
BE2C5EE11ED8480D00E9FAFA /* test_rapidPiPo.cpp */,
BE2C5EE21ED8480D00E9FAFA /* test_rapidXMM.cpp */,
BE2C5EE31ED8480D00E9FAFA /* test_signalProcessing.cpp */,
312C61B71FE958CB0085E283 /* test_trainingData.cpp */,
);
path = src;
sourceTree = "<group>";
......@@ -1079,6 +1101,7 @@
0BFFEF311E56085C00EF19A5 /* test_rapidXMM */,
0BFFEF3F1E5608C000EF19A5 /* test_signalProcessing */,
31D7B72C1E6B048100917757 /* test_rapidPiPo */,
312C61D31FE95A680085E283 /* test_trainingData */,
);
name = Products;
sourceTree = "<group>";
......@@ -1154,6 +1177,23 @@
productReference = 0BFFEF3F1E5608C000EF19A5 /* test_signalProcessing */;
productType = "com.apple.product-type.tool";
};
312C61B91FE95A680085E283 /* test_trainingData */ = {
isa = PBXNativeTarget;
buildConfigurationList = 312C61D01FE95A680085E283 /* Build configuration list for PBXNativeTarget "test_trainingData" */;
buildPhases = (
312C61BA1FE95A680085E283 /* Sources */,
312C61CE1FE95A680085E283 /* Frameworks */,
312C61CF1FE95A680085E283 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = test_trainingData;
productName = test_XMM;
productReference = 312C61D31FE95A680085E283 /* test_trainingData */;
productType = "com.apple.product-type.tool";
};
31D7B7121E6B048100917757 /* test_rapidPiPo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 31D7B7291E6B048100917757 /* Build configuration list for PBXNativeTarget "test_rapidPiPo" */;
......@@ -1211,6 +1251,7 @@
31D7B7121E6B048100917757 /* test_rapidPiPo */,
0BFFEF301E56085C00EF19A5 /* test_rapidXMM */,
0BFFEF3E1E5608C000EF19A5 /* test_signalProcessing */,
312C61B91FE95A680085E283 /* test_trainingData */,
);
};
/* End PBXProject section */
......@@ -1310,6 +1351,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
312C61BA1FE95A680085E283 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
312C61D41FE95A8F0085E283 /* test_trainingData.cpp in Sources */,
312C61BD1FE95A680085E283 /* trainingData.cpp in Sources */,
312C61CD1FE95A680085E283 /* jsoncpp.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
31D7B7131E6B048100917757 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
......@@ -1426,6 +1477,22 @@
};
name = Release;
};
312C61D11FE95A680085E283 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
312C61D21FE95A680085E283 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
31D7B72A1E6B048100917757 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
......@@ -1576,6 +1643,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
312C61D01FE95A680085E283 /* Build configuration list for PBXNativeTarget "test_trainingData" */ = {
isa = XCConfigurationList;
buildConfigurations = (
312C61D11FE95A680085E283 /* Debug */,
312C61D21FE95A680085E283 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
31D7B7291E6B048100917757 /* Build configuration list for PBXNativeTarget "test_rapidPiPo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment