Skip to content
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

Fix import error for rgb_to_grayscale #677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sipsmehta
Copy link

The import statement for rgb_to_grayscale was referencing the torchvision.transforms.functional_tensor module, which is not available in the current version of torchvision. Updated the import statement to use torchvision.transforms.functional instead, resolving the ModuleNotFoundError.

This commit fixes the issue where the script was failing to run due to the missing module. The change ensures compatibility with the installed version of torchvision and allows the script to execute successfully.

The import statement for rgb_to_grayscale was referencing the
torchvision.transforms.functional_tensor module, which is not available in
the current version of torchvision. Updated the import statement to use
torchvision.transforms.functional instead, resolving the ModuleNotFoundError.

This commit fixes the issue where the script was failing to run due to the
missing module. The change ensures compatibility with the installed version
of torchvision and allows the script to execute successfully.
@Elawphant
Copy link

This might break installations depending on older version of torchvision.
Instead, let's make it more compatible.

try:
    from torchvision.transforms.functional import rgb_to_grayscale
except ImportError:
    try:
        from torchvision.transforms.functional_tensor import rgb_to_grayscale
    except ImportError:
        raise ImportError("Failed to import rgb_to_grayscale from torchvision. Ensure you have a compatible version of torchvision installed.")

atisandev added a commit to atisandev/VQFR that referenced this pull request May 12, 2024
…ensor deprecation in 2024 January

Since 2024 January v0.17.0 of torchvision, the module torchvision.transforms.functional_tensor is removed and the module torchvision.transforms.functional is available.
https://github.com/pytorch/vision/releases/tag/v0.17.0

The code is proposed by @Elawfant in this issue of BasicSR: XPixelGroup/BasicSR#677
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants