Hi, all
How to save MNIST as .jpg format ?
Is it possible with
from torchvision.utils import save_image
?
(I use default dataloader from pytorch.)
Hi, all
How to save MNIST as .jpg format ?
Is it possible with
from torchvision.utils import save_image
?
(I use default dataloader from pytorch.)
Since the torchvision.datasets.MNIST
dataset returns PIL Images, if you don’t specify a transformation, the easiest way would be to directly save them:
dataset = datasets.MNIST(root=PATH)
for idx, (img, _) in enumerate(dataset):
img.save('{:05d}.jpg'.format(idx))
Sorry ptrblck,
How I can same this images. I use this command it save it but it is nothing in it just white.
real_batch = next(iter(trainloader))
fig=plt.figure()
plt.figure(figsize=(8,8))
plt.axis("off")
plt.title("Training Images")
plt.imshow(np.transpose(vutils.make_grid(real_batch[0].to(device)[:64], padding=2, normalize=True).cpu(),(1,2,0)))
fig.savefig(os.path.join(root_dirDurringTraining13+str(1)+str(2))+'Images.jpg',dpi=fig.dpi)
would you please guide me how to save it ?
Is plt.imshow
showing the expected figure and is only savefig
failing or do you also get a while output in imshow
?
I would recommend to check the min and max values of your image array, as matplotlib
could try to normalize the images thus potentially removing information.
it is solved I should used plt=plt.figure
many thanks