Hi everyone!
I did not find this question in the forum so I’ve decided to open a new topic (please let me know if this has already been answered elsewhere).
I’m following along with the Chapter 4 code in a new notebook from scratch and am running into an issue. When I use show_image
to display an image, I get an image with pixel colors of purples and yellows instead of black and white. When I run the Chapter 4 colab notebook (from the course site) with the same code, I see the black and white image as expected.
Here’s the colab I’m working in: https://colab.research.google.com/drive/19y5b86lfir64Arzj3_fQZGnsB-C-0AUI?usp=sharing
And here’s the code:
!pip install fastai --upgrade -q
!pip install fastcore --upgrade -q
path = untar_data(URLs.MNIST_SAMPLE)
Path.BASE_PATH = path
threes = (path/'train'/'3').ls().sorted()
sevens = (path/'train'/'7').ls().sorted()
seven_tensors = [tensor(Image.open(o)) for o in sevens]
three_tensors = [tensor(Image.open(o)) for o in threes]
stacked_sevens = torch.stack(seven_tensors).float()/255
stacked_threes = torch.stack(three_tensors).float()/255
mean3 = stacked_threes.mean(0)
show_image(mean3);
show_image(three_tensors[1]);
Here’s a screenshot of the output:
Even when I use show_image
for the .png
file, I see the same issue:
Thanks!
Vishal