1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #28752 from abhishek-gola:net_profiling

Added net profiling support #28752

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Abhishek Gola
2026-05-14 17:17:38 +05:30
committed by GitHub
parent 851e0196b4
commit 873a4635c6
12 changed files with 361 additions and 2 deletions
+7 -1
View File
@@ -5,6 +5,7 @@
#include <opencv2/dnn.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core/utils/logger.hpp>
#include "common.hpp"
@@ -139,6 +140,8 @@ static void showLegend(FontFace fontFace)
int main(int argc, char **argv)
{
utils::logging::setLogLevel(utils::logging::LOG_LEVEL_INFO);
CommandLineParser parser(argc, argv, keys);
const string modelName = parser.get<String>("@alias");
@@ -218,7 +221,8 @@ int main(int argc, char **argv)
Net net = readNetFromONNX(model, engine);
net.setPreferableBackend(getBackendID(backend));
net.setPreferableTarget(getTargetID(target));
//! [Read and initialize network]
net.setProfilingMode(DNN_PROFILE_SUMMARY);
//! [Read and initialize network]
// Create a window
static const string kWinName = "Deep learning semantic segmentation in OpenCV";
namedWindow(kWinName, WINDOW_AUTOSIZE);
@@ -263,6 +267,7 @@ int main(int argc, char **argv)
{
vector<Mat> output;
net.forward(output, net.getUnconnectedOutLayersNames());
net.printPerfProfile();
Mat pred = output[0].reshape(1, output[0].size[2]);
pred.convertTo(pred, CV_8U, 255.0);
@@ -284,6 +289,7 @@ int main(int argc, char **argv)
{
//! [Make forward pass]
Mat score = net.forward();
net.printPerfProfile();
//! [Make forward pass]
Mat segm;
colorizeSegmentation(score, segm);