Open sipsmehta opened 6 months ago
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.")
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.