Facing error in Customizing StyleGAN2 Chapter13
jemzipx opened this issue · 1 comments
At line
!python stylegan-encoder/align_images.py stylegan-encoder/raw_images/ stylegan-encoder/aligned_images/
!mv stylegan-encoder/aligned_images/* ./MyImage.jpg
the following error appears
Traceback (most recent call last):
File "stylegan-encoder/align_images.py", line 4, in
from keras.utils import get_file
ImportError: cannot import name 'get_file' from 'keras.utils' (/usr/local/lib/python3.7/dist-packages/keras/utils/init.py)
mv: cannot stat 'stylegan-encoder/aligned_images/*': No such file or directory
Also at the next line:
from PIL import Image
img = Image.open('MyImage.jpg')
show(np.array(img), sz=4, title='original')
!python encode_image.py ./MyImage.jpg\
pred_dlatents_myImage.npy\
--use_latent_finder true\
--image_to_latent_path ./trained_models/image_to_latent.pt
pred_dlatents = np.load('pred_dlatents_myImage.npy')
pred_dlatent = torch.from_numpy(pred_dlatents).float().cuda()
pred_image = latent2image(pred_dlatent)
show(pred_image, sz=4, title='synthesized')
this error shows up:
FileNotFoundError Traceback (most recent call last)
in ()
1 from PIL import Image
----> 2 img = Image.open('MyImage.jpg')
3 show(np.array(img), sz=4, title='original')
4
5 get_ipython().system('python encode_image.py ./MyImage.jpg pred_dlatents_myImage.npy --use_latent_finder true --image_to_latent_path ./trained_models/image_to_latent.pt')/usr/local/lib/python3.7/dist-packages/PIL/Image.py in open(fp, mode)
2841
2842 if filename:
-> 2843 fp = builtins.open(filename, "rb")
2844 exclusive_fp = True
2845FileNotFoundError: [Errno 2] No such file or directory: 'MyImage.jpg'
This is an error coming from an upstream library.. There's no easy way to fix this directly.
I suggest you change the line 4 in stylegan-encoder/align_images.py
from
from keras.utils import get_file
to
from tensorflow.keras.utils import get_file