mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33: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:
@@ -73,6 +73,7 @@ def main(func_args=None):
|
||||
help()
|
||||
exit(1)
|
||||
|
||||
cv.utils.logging.setLogLevel(cv.utils.logging.LOG_LEVEL_INFO)
|
||||
args.model = findModel(args.model, args.sha1)
|
||||
if args.labels is not None:
|
||||
args.labels = findFile(args.labels)
|
||||
@@ -105,6 +106,8 @@ def main(func_args=None):
|
||||
net = cv.dnn.readNetFromONNX(args.model, engine)
|
||||
net.setPreferableBackend(get_backend_id(args.backend))
|
||||
net.setPreferableTarget(get_target_id(args.target))
|
||||
if hasattr(cv.dnn, 'DNN_PROFILE_SUMMARY'):
|
||||
net.setProfilingMode(cv.dnn.DNN_PROFILE_SUMMARY)
|
||||
|
||||
winName = 'Deep learning semantic segmentation in OpenCV'
|
||||
cv.namedWindow(winName, cv.WINDOW_AUTOSIZE)
|
||||
@@ -138,6 +141,7 @@ def main(func_args=None):
|
||||
t0 = cv.getTickCount()
|
||||
if args.alias == 'u2netp':
|
||||
output = net.forward(net.getUnconnectedOutLayersNames())
|
||||
net.printPerfProfile()
|
||||
pred = output[0][0, 0, :, :]
|
||||
mask = (pred * 255).astype(np.uint8)
|
||||
mask = cv.resize(mask, (frame.shape[1], frame.shape[0]), interpolation=cv.INTER_AREA)
|
||||
@@ -149,6 +153,7 @@ def main(func_args=None):
|
||||
frame = cv.addWeighted(frame, 0.25, foreground_overlay, 0.75, 0)
|
||||
else:
|
||||
score = net.forward()
|
||||
net.printPerfProfile()
|
||||
|
||||
numClasses = score.shape[1]
|
||||
height = score.shape[2]
|
||||
@@ -176,4 +181,4 @@ def main(func_args=None):
|
||||
cv.imshow(winName, frame)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user