Plt.imshow shows weird data augmentation when I have none

The below piece of code gives me back really weird data augmented image. There are no other transformations besides the Resize. I am using pytorch 0.40


transformed_dataset = data_sets(csv_path=csv_path,
                                image_path = image_path,
                                transform = transforms.Compose([
                                ]) )

dataloader = DataLoader(transformed_dataset, batch_size=2,
                        shuffle=True, num_workers=0)

for idx, _ in enumerate(dataloader):
    for _ in _['input']:
        img = _.view(256, 256, 3).numpy()

I am really not familiar with matplotlib so maybe this is the default behavior?

What is the photo supposed to look like? Several possibilities are the data is floating point and imshow is interpreting it as an integer (expected range is 0-255) but the data is float (expected range is 0-1) or vice versa.

Its suppose to be a single color image of a black and white line art. I didn’t want to convert it to gray scale because I want to train a classifier to ID the between color and black/white lineart.test_issue

Could you try to use img = img.permute(1, 2, 0) instead of the view call?

Thanks! That fixed it, do you know why view didn’t work? Edited: A quick loop shows permute works for some images but not on all of them?

Edited: Nvm there was left over old code. Thanks for the solution!