Commit 986152ec authored by pbethge's avatar pbethge
Browse files

send whole output vector

parent 28cf6221
http -v -j POST https://thingsboard.zkm.de/api/v1/rFKmcjtHSLgVvrT6NaCB/telemetry lang=$1
http -v -j POST https://thingsboard.zkm.de/api/v1/rFKmcjtHSLgVvrT6NaCB/telemetry $*
......@@ -61,7 +61,7 @@ class AudioClassifier : public ofxTF2::Model {
public:
void classify(AudioBufferFifo & bufferFifo, const std::size_t downsamplingFactor,
int & argMax, float & prob) {
int & argMax, float & prob, std::vector<float> & outputVector) {
SimpleAudioBuffer sample;
......@@ -87,7 +87,6 @@ class AudioClassifier : public ofxTF2::Model {
auto output = runModel(input);
// convert the output to std::vector
std::vector<float> outputVector;
ofxTF2::tensorToVector(output, outputVector);
// get element with highest probabilty
......
......@@ -87,6 +87,16 @@ void ofApp::setup() {
}
}
std::string resultTOString(Labels labelsMap, std::vector<float> outputVector){
std::string result;
for (size_t i = 0; i < outputVector.size(); i++)
{
result.append(labelsMap[i] + "=" + std::to_string(outputVector[i]) + " ");
}
return result;
}
//--------------------------------------------------------------
void ofApp::update() {
......@@ -103,12 +113,16 @@ void ofApp::update() {
// inference, sets argMax and prob after running model
int argMax;
float prob;
model.classify(sampleBuffers, downsamplingFactor, argMax, prob);
std::vector<float> outputVector;
model.classify(sampleBuffers, downsamplingFactor, argMax, prob, outputVector);
// only send & display label when probabilty is high enough
if(prob >= minConfidence) {
displayLabel = labelsMap[argMax];
std::string cmd = ofToDataPath("send_http.sh") + " " + std::to_string(argMax);
std::string cmd_args = resultTOString(labelsMap, outputVector);
cmd_args.append("selected=" + displayLabel);
std::string cmd = ofToDataPath("send_http.sh") + " " + cmd_args;
ofLog() << cmd;
ofSystem(cmd);
ofxOscMessage message;
message.setAddress("/lang");
......
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