Skip to content

how can i use dnn_superres with GPU cuda. #3047

Open
@epsilon-deltta

Description

@epsilon-deltta

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' )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions