tg-bomze / BabyGAN

StyleGAN-based predictor of children's faces from photos of theoretical parents.
341 stars 63 forks source link

An Error in 'Get latent representation' #9

Closed SupersuROOT closed 2 years ago

SupersuROOT commented 2 years ago
Using TensorFlow backend.
Traceback (most recent call last):
  File "encode_images.py", line 242, in <module>
    main()
  File "encode_images.py", line 116, in main
    with dnnlib.util.open_url(args.model_url, cache_dir=config.cache_dir) as f:
  File "/content/BabyGAN/dnnlib/util.py", line 350, in open_url
    assert is_url(url)
AssertionError
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-13-d8889cdf12f8> in <module>()
     17 tflib.init_tf()
     18 URL_FFHQ = "/content/BabyGAN/karras2019stylegan-ffhq-1024x1024.pkl"
---> 19 with dnnlib.util.open_url(URL_FFHQ, cache_dir=config.cache_dir) as f:
     20     generator_network, discriminator_network, Gs_network = pickle.load(f)
     21 generator = Generator(Gs_network, batch_size=1, randomize_noise=False)

/content/BabyGAN/dnnlib/util.py in open_url(url, cache_dir, num_attempts, verbose)
    348         return open(url, 'rb')
    349 
--> 350     assert is_url(url)
    351     assert num_attempts >= 1
    352 
GarryNeKasparov commented 2 years ago

The problem is that the karras2019stylegan-ffhq-1024x1024.pkl file doesn't exist in the BabyGan folder. To solve it, go to NVlabs/stylegan github repository, then find StyleGan folder Gdrive link. There will be networks folder, add it's shortcut to your Gdrive. Now, in notebook check code of second cell and find !cp '/content/drive/My Drive/BabyGAN/karras2019stylegan-ffhq-1024x1024.pkl' '/content/BabyGAN', replace it by !cp '/content/drive/MyDrive/networks/karras2019stylegan-ffhq-1024x1024.pkl' '/content/BabyGAN'.

tg-bomze commented 2 years ago

Fixed

SupersuROOT commented 2 years ago

The problem is that the karras2019stylegan-ffhq-1024x1024.pkl file doesn't exist in the BabyGan folder. To solve it, go to NVlabs/stylegan github repository, then find StyleGan folder Gdrive link. There will be networks folder, add it's shortcut to your Gdrive. Now, in notebook check code of second cell and find !cp '/content/drive/My Drive/BabyGAN/karras2019stylegan-ffhq-1024x1024.pkl' '/content/BabyGAN', replace it by !cp '/content/drive/MyDrive/networks/karras2019stylegan-ffhq-1024x1024.pkl' '/content/BabyGAN'.

Thank you!!! It can work now.