Giter Club home page Giter Club logo

Comments (3)

betterze avatar betterze commented on September 27, 2024 1

Problem solved. Just need to load pkl in tf1, then save it as cktp.

code from https://gitmemory.com/issue/moono/stylegan-reproduced/1/486484910

import os
import pprint
import pickle
import numpy as np
import PIL.Image
import dnnlib
import dnnlib.tflib as tflib
import config

import tensorflow as tf


def main():
    # Initialize TensorFlow.
    tflib.init_tf()

    # Load pre-trained network.
    url = 'https://drive.google.com/uc?id=1MEGjdvVpUsu1jB4zrXZN7Y4kBBOzizDQ' # karras2019stylegan-ffhq-1024x1024.pkl
    with dnnlib.util.open_url(url, cache_dir=config.cache_dir) as f:
        _G, _D, Gs = pickle.load(f)
        # _G = Instantaneous snapshot of the generator. Mainly useful for resuming a previous training run.
        # _D = Instantaneous snapshot of the discriminator. Mainly useful for resuming a previous training run.
        # Gs = Long-term average of the generator. Yields higher-quality results than the instantaneous snapshot.

    # Print network details.
    Gs.print_layers()

    # t_var = tf.trainable_variables()
    # pprint.pprint(t_var)

    saver = tf.train.Saver()

    save_path = saver.save(tf.get_default_session(), "./model.ckpt")


if __name__ == "__main__":
    main()

from stylegan2-tf-2.x.

starrabb1t avatar starrabb1t commented on September 27, 2024

But module dnnlib uses tensorflow v1. I tried to replace tensorflow to tensorflow.compat.v1 in dnnlib, but it doesn't work unfortunately.

I converted it using this colab notebook finally. May be useful for those who don't want to have a deal with docker :)

from stylegan2-tf-2.x.

betterze avatar betterze commented on September 27, 2024

@starrabb1t I mean save the weight in tf1, then you can use tf2 to open this model and load weights.

from stylegan2-tf-2.x.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.