# Why do I get a different image at the same index?

I have the following code portion:

``````images = []
image_labels = []

inputs, labels = data
inputs, labels = inputs.to(device), labels.to(device)
inputs, labels = inputs.float(), labels.float()
images.append(inputs)
image_labels.append(labels)

image = images[7]
image = image[0,...].permute([1,2,0])
image = image.numpy()
image = (image * 255).astype(np.uint8)
img = Image.fromarray(image,'RGB')
img.show()
``````

As you can see, I’m trying to display the image at index 7. However, every time I run the code I get a different image displayed although using the same index, why is that?

The image displayed also is like degraded and has less quality than the original one.

Any thoughts on that?

Thanks.

Did you make your train_loader with `shuffle=True`?

Also I ran into problems where fetching all files wasn’t necessarily in the same order every time (i.e. if I have a folder of 10k files, sometimes the order that they are retrieved are different). To avoid this, you can sort your retrieved files (assuming you’re working with files)

1 Like

Thanks for your kind reply. Yes, the issue was the `shuffle=True`.

1 Like

Nice! Don’t forget to mark as solution in case others have same problem

1 Like