Browse Source

fixed batch emotion

master
cailean 3 weeks ago
parent
commit
dd08df5f4f
  1. 26
      src/ofApp.cpp

26
src/ofApp.cpp

@ -70,7 +70,7 @@ void ofApp::update(){
Create a dummy initial input of batch_size = 5, as Create a dummy initial input of batch_size = 5, as
when initialising the model, it will attempt to create a space in memory for this array. when initialising the model, it will attempt to create a space in memory for this array.
If the batch_size does change it will completely slow down inference, due to how the cudnn_search_algo is set. If the batch_size does change it will completely slow down inference, due to how the cudnn_search_algo is set.
None of the other search alogithms bar EXHAUSTIVE will work.. no idead why. None of the other search alogithms bar EXHAUSTIVE will work.. no idea why.
*/ */
for(int i = 0; i < emotionImageMaxBatchSize; i++){ for(int i = 0; i < emotionImageMaxBatchSize; i++){
tempImage.setFromPixels(emoteImage.getPixels()); tempImage.setFromPixels(emoteImage.getPixels());
@ -137,19 +137,17 @@ void ofApp::inferEmotionalState(){
auto output_shap = output_tensor.GetTensorTypeAndShapeInfo().GetShape(); auto output_shap = output_tensor.GetTensorTypeAndShapeInfo().GetShape();
size_t batch_size = output_shap[0]; // Number of images in the batch size_t batch_size = output_shap[0]; // Number of images in the batch
size_t num_classes = output_shap[1]; // Number of emotion classes size_t num_classes = output_shap[1]; // Number of emotion classes
std::cout << batch_size << " : " << num_classes << std::endl;
float* emotional_data = output_tensor.GetTensorMutableData<float>();
// for(int i = 0; i < max_faces_to_process; ++i){
// auto& face = detected_faces[i]; for (size_t i = 0; i < max_faces_to_process; i++){
// faceDetector.CropFaceToImage(img, face, emoteImage);
// tempImage.setFromPixels(emoteImage.getPixels()); float* emotion_values = emotional_data + i * num_classes;
// auto emotion_output_tensor = emotion.Run(tempImage);
// float* emotional_data = emotion_output_tensor.front().GetTensorMutableData<float>(); emotion.Softmax(emotion_values, num_classes);
// emotion.Softmax(emotional_data, 7);
// face.box.SetEmotionState(emotional_data); detected_faces[i].box.SetEmotionState(emotion_values);
// } }
std::cout << croppedFaces.size() << std::endl;
} }
//-------------------------------------------------------------- //--------------------------------------------------------------

Loading…
Cancel
Save