Hello,
I’m trying to save the output image of my autoencoder.
Here is some of my code:
def train(train_dl, inp, out, model):   
    optimizer=torch.optim.Adam(model.parameters(), lr=args.learning_rate)
    model.train()
    train_loss=0.0
    for idx, (data, label) in enumerate(train_dl):
        data, label= Variable(data), Variable(label)
        out, mu, var=model(data)
        loss=loss_fct(data, out, mu, var)
        train_loss+=loss.data[0]
        model.zero_grad()
        loss.backward()
        optimizer.step()
    save_image(data[0], inp)
    save_image(out[0], out)
    av_loss= train_loss / len(train_dl.dataset)     
    return mu, var, av_loss

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Autoencoder')
    parser.add_argument('-oimg','--output-img', type=str, default='output12.png', metavar='',
                    help='output image (default: output12.png)')
    parser.add_argument('-iimg','--input-img', type=str, default='input12.png', metavar='',
                    help='input image (default: input12.png)')
    parser.add_argument('-outp','--output', type=str, default='out.txt', metavar='',
                    help='output file (default: out.txt)')
    args = parser.parse_args()

transform1=transforms.Compose([transforms.ToTensor()])
train1=ImageFolder("/home/uz/zaianir/scratch/DB/sentinel_data1", transform1)
train_dl=torch.utils.data.DataLoader(train1, batch_size=args.batch_size, shuffle=True)
model=VAE() 
mu, var, loss= train(train_dl, args.input_img, args.output_img, model)

But I get this error:
Traceback (most recent call last):
  File "/home/uz/zaianir/scratch/vae_sentinel1.py", line 112, in <module>
    mu, var, loss= train(train_dl, args.input_img, args.output_img, model)
  File "/home/uz/zaianir/scratch/vae_sentinel1.py", line 84, in train
    save_image(out[0], out)
  File "/home/uz/zaianir/scratch/.conda/envs/myenv/lib/python3.6/site-packages/torchvision/utils.py", line 104, in save_image
    im.save(filename)
  File "/home/uz/zaianir/scratch/.conda/envs/myenv/lib/python3.6/site-packages/PIL/Image.py", line 1989, in save
    raise ValueError('unknown file extension: {}'.format(ext))
ValueError: unknown file extension:

Can you please help me?
Thank you very much.