small-dataset-image-generation icon indicating copy to clipboard operation
small-dataset-image-generation copied to clipboard

How to load .h5 checkpoint?

Open chingisooinar opened this issue 3 years ago • 1 comments

Hello, I want to run inference so I need to load my '.h5' checkpoint. I don't have much experience with chainer framework. Could you please let me know how I can do that and run inference?

chingisooinar avatar Dec 28 '21 08:12 chingisooinar

You could do the following for inference

  1. Initialize the generator and load pretrained weights. e.g. biggan based model gen = AdaBIGGAN(config, datasize, comm=comm) chainer.serializers.load_npz("your_pretrained_model.h5", gen.gen) gen.to_gpu(device) # send to gpu if necessary gen.gen.to_gpu(device) # send to gpu if necessary

  2. Random sampling e.g. randomly sample 5 images with temperature=0.5 without truncation random_imgs = gen.random(tmp=0.5, n=5, truncate=False)

  3. Interpolation e.g. interpolation between 0th and 1st image interpolated_imgs = gen.interpolate(self, source=0, dest=1, num=5)

I don't actually run it now, so it may not work. Please let me know if it doesn't work.

nogu-atsu avatar Dec 29 '21 13:12 nogu-atsu