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

Potentially redundant code in image-> tensor conversion? #26

Open
mazatov opened this issue Oct 9, 2023 · 0 comments
Open

Potentially redundant code in image-> tensor conversion? #26

mazatov opened this issue Oct 9, 2023 · 0 comments

Comments

@mazatov
Copy link

mazatov commented Oct 9, 2023

I was a bit confused by the lines 62,63 in your code line 62

Seems like you are converting from numpy to tensor, back to numpy, and then back to tensor. Wouldn't there by an easier way to do this?

    image = transforms.ToTensor()(image)
    image = torch.tensor(np.array([image.numpy()]))

Would this achieve the same?

image = torch.tensor(np.expand_dims(np.rollaxis(image,2)/255.0, -1))

Also is the first dimension of the image, batch? Could we technically pass multiple images here?

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

No branches or pull requests

1 participant