I am using the code from zalando implemented as a progressive GAN by Nvidia. See: https://github.com/zalandoresearch/disentangling_conditional_gans
They use 3 networks while training: G, D and Gs. All three models are an instance of a Network class defined in https://github.com/zalandoresearch/disentangling_conditional_gans/blob/master/tfutil.py#L424
These models are stored and loaded using many helper functions which save the 3 models using python's pickle format as *.pkl.
I am only interested in exporting the Gs model.
How do I convert it into a saved model (as the code doesn't use tf.Saver) and finally a frozen model so that I can easily infer.
Upon loading the models, I do:
allvars = [n.name for n in tf.get_default_graph().as_graph_def().node]
Gs_vars = [i for i in allvars if i.split('/')[0] == 'Gs']
However, when running this:
Gs_saver = tf.train.Saver({"Gs": Gs_vars})
it throws an error saying:
*** ValueError: Slices must all be Variables: Gs/latents_in
The correct implementation of using the Gs model is:
images = Gs.run(latents, labels, masks, minibatch_size=minibatch_size, num_gpus=config.num_gpus, out_mul=127.5, out_add=127.5, out_shrink=image_shrink, out_dtype=np.uint8)
Gs requires 3 inputs which are stored as Gs/latents_in, Gs/masks_in and Gs/labels_in.