yuval-alaluf / stylegan3-editing

Official Implementation of "Third Time's the Charm? Image and Video Editing with StyleGAN3" (AIM ECCVW 2022) https://arxiv.org/abs/2201.13433
https://yuval-alaluf.github.io/stylegan3-editing/
MIT License
654 stars 73 forks source link

Runtime nan+-nan #32

Closed ikcla closed 2 years ago

ikcla commented 2 years ago

Used docker pytorch/pytorch:1.10.0-cuda11.3-cudnn8-devel.
Create Environtment: conda env create -f environment/sg3_env.yml But I got error when inferenced as below. Any ideas how to fix it?

command:

python inversion/scripts/inference_iterative.py --output_path experiments/restyle_e4e_ffhq_encode/inference --checkpoint_path pretrained_models/restyle_e4e_ffhq.pt --data_path /usr/src/myapp/stylegan3-editing/ --test_batch_size 4 --test_workers 1 --n_iters_per_batch 3 --landmarks_transforms_path output/landmarks_transforms.npy

output:

Loading ReStyle e4e from checkpoint: pretrained_models/restyle_e4e_ffhq.pt Loading StyleGAN3 generator from path: None Done! Model successfully loaded! Loading dataset for ffhq_encode Setting up PyTorch plugin "filtered_lrelu_plugin"... Done. 0it [00:00, ?it/s] /opt/conda/envs/sg3_env/lib/python3.6/site-packages/numpy/core/fromnumeric.py:3373: RuntimeWarning: Mean of empty slice. out=out, **kwargs) /opt/conda/envs/sg3_env/lib/python3.6/site-packages/numpy/core/_methods.py:170: RuntimeWarning: invalid value encountered in double_scalars ret = ret.dtype.type(ret / rcount) /opt/conda/envs/sg3_env/lib/python3.6/site-packages/numpy/core/_methods.py:234: RuntimeWarning: Degrees of freedom <= 0 for slice keepdims=keepdims) /opt/conda/envs/sg3_env/lib/python3.6/site-packages/numpy/core/_methods.py:195: RuntimeWarning: invalid value encountered in true_divide arrmean, rcount, out=arrmean, casting='unsafe', subok=False) /opt/conda/envs/sg3_env/lib/python3.6/site-packages/numpy/core/_methods.py:226: RuntimeWarning: invalid value encountered in double_scalars ret = ret.dtype.type(ret / rcount) Runtime nan+-nan

Originally posted by @ikcla in https://github.com/yuval-alaluf/stylegan3-editing/issues/31#issuecomment-1168829518

ZziTaiLeo commented 2 years ago

Maybe is your '--data_path' or '--landmarks_transforms_path' not correctly?

ikcla commented 2 years ago

thanks for your response, but wouldn't it give me an error fiile/dir not found in that case?

ikcla commented 2 years ago

--landmarks_transforms_path is correctly pointd to landmarks_transforms.npy aligned image is in /usr/src/myapp/stylegan3-editing/data_aligned so I passed in --data_path /usr/src/myapp/stylegan3-editing/ => it will look for /usr/src/myapp/stylegan3-editing/data_aligned/image.png which is also correct The error did not give me any meaningful messages to trace the code beside some warning from python library.

yuval-alaluf commented 2 years ago

Based on the logs you posted there is a part that says:

0it [00:00, ?it/s]

This indicates that there are no valid images found in your directory or something with the names in your landmarks npy file matching the file names. What I would do is try to run this in debug mode and put a breakpoint after defining your dataset. Then, verify that everything in your dataset object looks good.