Skip to content

Commit

Permalink
cpp demos: logging fix (#2642)
Browse files Browse the repository at this point in the history
* replace \n with slog::endl, print statstream only if it isn't empty

* fix mistake
  • Loading branch information
ivikhrev authored Jul 27, 2021
1 parent 0a70225 commit 3bc41b5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demos/common/cpp/models/src/classification_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ClassificationModel::prepareInputsOutputs(InferenceEngine::CNNNetwork& cnnN
throw std::runtime_error("The model provides " + std::to_string(outSizeVector[1]) + " classes, but " + std::to_string(nTop) + " labels are requested to be predicted");
if (outSizeVector[1] == labels.size() + 1) {
labels.insert(labels.begin(), "other");
slog::warn << "\tInserted 'other' label as first.\n";
slog::warn << "\tInserted 'other' label as first." << slog::endl;
}
else if (outSizeVector[1] != labels.size())
throw std::logic_error("Model's number of classes and parsed labels must match (" + std::to_string(outSizeVector[1]) + " and " + std::to_string(labels.size()) + ')');
Expand Down
2 changes: 1 addition & 1 deletion demos/common/cpp/models/src/deblurring_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ std::shared_ptr<InternalModelData> DeblurringModel::preprocess(const InputData&
cv::copyMakeBorder(image, resizedImage, 0, bottom, 0, right,
cv::BORDER_CONSTANT, 0);
} else {
slog::warn << "\tChosen model aspect ratio doesn't match image aspect ratio\n";
slog::warn << "\tChosen model aspect ratio doesn't match image aspect ratio" << slog::endl;
cv::resize(image, resizedImage, cv::Size(netInputWidth, netInputHeight));
}
Blob::Ptr frameBlob = request->GetBlob(inputsNames[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ std::shared_ptr<InternalModelData> HpeAssociativeEmbedding::preprocess(const Inp
auto paddedImage = resizeImageExt(image, inputLayerSize.width, inputLayerSize.height, resizeMode, true, &roi);
if (inputLayerSize.height - stride >= roi.height
|| inputLayerSize.width - stride >= roi.width) {
slog::warn << "\tChosen model aspect ratio doesn't match image aspect ratio\n";
slog::warn << "\tChosen model aspect ratio doesn't match image aspect ratio" << slog::endl;
}
request->SetBlob(inputsNames[0], wrapMat2Blob(paddedImage));
/* IE::Blob::Ptr from wrapMat2Blob() doesn't own data. Save the image to avoid deallocation before inference */
Expand Down
2 changes: 1 addition & 1 deletion demos/common/cpp/models/src/hpe_model_openpose.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ std::shared_ptr<InternalModelData> HPEOpenPose::preprocess(const InputData& inpu
throw std::runtime_error("The image aspect ratio doesn't fit current model shape");

if (inputLayerSize.width - stride >= roi.width) {
slog::warn << "\tChosen model aspect ratio doesn't match image aspect ratio\n";
slog::warn << "\tChosen model aspect ratio doesn't match image aspect ratio" << slog::endl;
}

request->SetBlob(inputsNames[0], wrapMat2Blob(paddedImage));
Expand Down
4 changes: 3 additions & 1 deletion demos/smart_classroom_demo/cpp_gapi/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ int main(int argc, char* argv[]) {
videoWriter << proc;
};
/** Console log, if exists **/
slog::debug << stream_log;
if (!stream_log.empty()) {
slog::debug << stream_log << slog::endl;
}
}
auto elapsed = std::chrono::high_resolution_clock::now() - started_all;
work_time_ms_all += std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count();
Expand Down

0 comments on commit 3bc41b5

Please sign in to comment.