-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create CUDA backend support for dnn_superres #2599
Conversation
Not sure if this is the best way. Perhaps better to to create getter for 'net' so user can set backend themselves.
void DnnSuperResImpl::setCUDA() | ||
{ | ||
net.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); | ||
net.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More robust solution is to proxy these calls instead:
- setPreferableBackend
- setPreferableTarget
Otherwise we will get soon setOpenCL, setCUDA_FP16, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like this? (See new commit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, good. Should I add a note in the tutorials somewhere? And I don't think a test is needed (or possible) for this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this change is straightforward and doesn't require extra documentation or tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@Saafke which networks have you tried for upscaling? Are the networks publicly available? |
@tompollok It works with all four available models. Check the tutorial for how to use this module. This blog is also helpful. |
Hi there,
This PR allows users to set CUDA backend in the dnn_superres module. Now users can use their GPU's for inference while upscaling images via the neural networks. I've tried a few images, and I've seen around an 6x increase in speed (GTX 1080Ti).
I'm not sure this is the best way of doing this. Perhaps it is better to also allow users to choose other types of backends? What do you think? I'll wait for the feedback before adding a tutorial (and test?) for this.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.