Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

have a look at the classification example , you can reshape() the 4d Mat into a 2d one, and then find the largest value:

    //! [Get a class with a highest score]
    Point classIdPoint;
    double confidence;
    minMaxLoc(prob.reshape(1, 1), 0, &confidence, 0, &classIdPoint);
    int classId = classIdPoint.x;

have a look at the classification example ,

your network reports age and gender at the same time, in different outputs:

vector<string> outnames = {"prob", "age_conv3"};
vector<Mat> outputs;
net.forward(outnames, outputs);
Mat prob = outputs[0];
Mat age_conv3 = outputs[1];

for the gender output (2 values), you can reshape() the 4d Mat into a 2d one, and then find the largest value:

 //! [Get a class with a highest score]
 Point classIdPoint;
 double confidence;
 minMaxLoc(prob.reshape(1, 1), 0, &confidence, 0, &classIdPoint);
 int classId = classIdPoint.x;

for the age output, there is only a single value:

float age = 0.01 * age_conv3.reshape(1, 1).at<float>(0,0);

have a look at the classification example ,

your network reports age and gender at the same time, in different outputs:

vector<string> outnames = {"prob", "age_conv3"};
vector<Mat> outputs;
net.forward(outnames, outputs);
Mat prob = outputs[0];
Mat age_conv3 = outputs[1];

for the gender output (2 values), you can reshape() the 4d Mat into a 2d one, and then find the largest value:value, have a look at the classification example :

//! [Get a class with a highest score]
Point classIdPoint;
double confidence;
minMaxLoc(prob.reshape(1, 1), 0, &confidence, 0, &classIdPoint);
int classId = classIdPoint.x;

for the age output, there is only a single value:

float age = 0.01 100 * age_conv3.reshape(1, 1).at<float>(0,0);