value error: could not find a format to write the specified file in s% mode


I am trying to run the following interpolation python code.

MNIST latent interpolation

I used python --start-num 1 --end-num 3 --out-name 1-3 command to run the code and faced the error:

value error: could not find a format to write the specified file in s mode (Please check the screenshot).

Error screenshot

Any hint will be appreciated.


The problem could be generated by --out-name 1-3.

imageio.mimsave(os.path.join(out_path, out_name), resized_imgs) is fuction that create your file. This requires extension of file example ‘file.gif’.

Try to run your code in like this :
python --start-num 1 --end-num 3 --out-name name.gif

In addition, I enclose all the commands allowed:

parser.add_argument('-t', '--train',action="store_true", default=False)
parser.add_argument('-e', '--epochs',type=int, default=250, help='number of epochs for training')

parser.add_argument('-b', '--batch-size',type=int, default=400, help='batchsize used in training')

parser.add_argument('-s', '--save-interval', type=int, default=50, help='save model every interval')

parser.add_argument('-g', '--generate',  action="store_true", default=True)

parser.add_argument('-i', '--imsize',    type=int, default=128,  help='image size of generated gif')

parser.add_argument('-a', '--start-num', type=int, default=9,help='count down/up starts with this number')

parser.add_argument('-z', '--end-num',   type=int, default=0,    help='count down/up ends with this number')

parser.add_argument('-n', '--n-steps',   type=int, default=30,   help='number of steps used in latent interpolation')

parser.add_argument('-o', '--out-path',  type=str, default="output", help='path to generated gif')

parser.add_argument('-l', '--out-name',  type=str, default="countdown.gif", help='name of generated gif')

parser.add_argument('-m', '--model-path',type=str, default="models/model-250.h5", help='path to saved model')

Answered By – Francesco

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published