Skip to content
Discussion options

You must be logged in to vote

Both performs same function.

The only difference lies in how you import

import torchvision.transforms as transforms
import torch

# Using torchvision.transforms.ToTensor()
transform_1 = transforms.ToTensor()
image_tensor_1 = transform_1(pil_image)  

# Using transform = ToTensor()
from torchvision.transforms import ToTensor

transform_2 = ToTensor()
image_tensor_2 = transform_2(pil_image)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@GAuravY19
Comment options

Answer selected by GAuravY19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants