opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.36k stars 5.75k forks source link

how can i use dnn_superres with GPU cuda. #3047

Open epsilon-deltta opened 3 years ago

epsilon-deltta commented 3 years ago

When i operated this code, it worked on the cpu. So, ... how can i move that model to NVIDIA GPU (like, 'cuda:0')

import cv2
from cv2 import dnn_superres
# Create an SR object - only function that differs from c++ code
sr = dnn_superres.DnnSuperResImpl_create()
# Read image
image = cv2.imread('./image.png')
# Read the desired model
path = "EDSR_x4.pb"
sr.readModel(path)
# Set the desired model and scale to get correct pre- and post-processing
sr.setModel("edsr", 4)
# Upscale the image
result = sr.upsample(image)
# Save the image
cv2.imwrite("./upscaled.png", result)

I hope kind of this following code.

sr.readModel(path, device='cuda:0' )
PodoprikhinMaxim commented 1 year ago

did u resolve the issue?