Skip to content

[BUG]cvcuda.resize not support cvcuda.Interp.LANCZOS #222

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

Open
Dribblelife opened this issue Dec 11, 2024 · 2 comments
Open

[BUG]cvcuda.resize not support cvcuda.Interp.LANCZOS #222

Dribblelife opened this issue Dec 11, 2024 · 2 comments
Labels
documentation Improvements or additions to documentation enhancement Enhance or improve existing feature, operator, or documentation feature request New feature or request

Comments

@Dribblelife
Copy link

Describe the bug
we use cvcuda to resize imgs, but found resize param not support cvcuda.Interp.LANCZOS

Steps/Code to reproduce bug
def clip_img2_tensor(self, imgs):
center_croped_tensor_hwc_list = []
for frame in imgs:
h = frame.height
w = frame.width
ratio = float(256.0) / min(w, h)
w_resize, h_resize = int(w * ratio), int(h * ratio)
frame_tensor_hwc = cvcuda.as_tensor(frame,"HWC")
resized_frame_tensor_hwc = cvcuda.resize(frame_tensor_hwc,(h_resize, w_resize, 3), cvcuda.Interp.LANCZOS)
# center_croped_tensor_hwc = cvcuda.center_crop(resized_frame_tensor_hwc, (224, 224))
center_croped_tensor_hwc_list.append(resized_frame_tensor_hwc)
stack_center_croped_tensor_hwc = cvcuda.stack(center_croped_tensor_hwc_list)
nvcvConvertTensor = cvcuda.convertto(stack_center_croped_tensor_hwc, np.float32, scale=1 / 255)

    mean_tensor = nvcv.as_tensor(self.scaleTensor, "NHWC")
    std_tensor = nvcv.as_tensor(self.stdTensor, "NHWC")
    nvcvNormTensor = cvcuda.normalize(nvcvConvertTensor, mean_tensor, std_tensor, cvcuda.NormalizeFlags.SCALE_IS_STDDEV)
    nvcvPreprocessedTensor = cvcuda.reformat(nvcvNormTensor, "NCHW")
    torch_preprocessed_tensor = torch.as_tensor(nvcvPreprocessedTensor.cuda(), device="cuda")
    return torch_preprocessed_tensor

Err is:
message: RuntimeError: NVCV_ERROR_INVALID_ARGUMENT: Invalid interpolation

Expected behavior
how can i use LANCZOS to resize img?

@Dribblelife Dribblelife added the bug Something isn't working as expected (software, install, documentation) label Dec 11, 2024
@Dribblelife
Copy link
Author

I would like to move the existing OpenCV operations to the GPU, so I want to rewrite the original image = cv2.resize(image, (w_resize, h_resize), interpolation=cv2.INTER_LANCZOS4) to use cvcuda.resize. According to the official documentation, cvcuda implements this method.

@dlesage-nvidia
Copy link
Contributor

Hi @Dribblelife, thank you for your interest and patience!
Indeed, Resize does not support LANCZOS, while PillowResize and HQResize do.
I understand that the documentation is ambiguous, I mark this issue as feature requests:

  1. to update the documentation of Resize to clarify what interpolation modes are supported
  2. to add LANCZOS interpolation to Resize
    In the meantime, I encourage you to look into PillowResize and HQResize to see if they meet your needs.
    Thank you,

@dlesage-nvidia dlesage-nvidia added feature request New feature or request and removed bug Something isn't working as expected (software, install, documentation) labels Mar 14, 2025
@shiremathNV shiremathNV added documentation Improvements or additions to documentation enhancement Enhance or improve existing feature, operator, or documentation labels Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement Enhance or improve existing feature, operator, or documentation feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants