Skip to content

How to apply same transform to image and label using 'Dataset'? #1788

Discussion options

You must be logged in to vote

Sorry we have found my problem in plotting the images. I have used

train_ds = Dataset(data=train_files, transform=train_transform)
print(f"image shape: {train_ds['image'].shape}")
plt.figure("image", (15, 6))
plt.subplot(1, 2, 1)
plt.imshow(train_ds[0]["image"][0,25,:, :])
plt.subplot(1, 2, 2)
plt.imshow(train_ds[0]["label"][0,25, :, :])
plt.show() 

In the above I apply transform in the train_files each time when I plot train_ds separately. Instead, I should plot in this way:

train_ds = Dataset(data=train_files, transform=train_transform)
plot_train=train_ds[0]
print(f"image shape: {plot_train['image'].shape}")
plt.figure("image", (15, 6))
plt.subplot(1, 2, 1)
plt.imshow(plot_train["imag…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@rijobro
Comment options

rijobro Mar 17, 2021
Collaborator

@rijobro
Comment options

rijobro Mar 17, 2021
Collaborator

@ivychancheers
Comment options

@wyli
Comment options

wyli Mar 17, 2021
Collaborator

@rijobro
Comment options

rijobro Mar 17, 2021
Collaborator

Comment options

You must be logged in to vote
0 replies
Answer selected by wyli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants