autonomousvision / stylegan-xl

[SIGGRAPH'22] StyleGAN-XL: Scaling StyleGAN to Large Diverse Datasets
MIT License
961 stars 113 forks source link

Error while running `run_inversion.py` example #111

Open Vibhu04 opened 1 year ago

Vibhu04 commented 1 year ago

I ran the following example code provided in the readme:

python run_inversion.py --outdir=inversion_out \
  --target media/jay.png \
  --inv-steps 1000 --run-pti --pti-steps 350 \
  --network=https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet512.pkl

and got this error:

Loading networks from "https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet512.pkl"...
Downloading https://s3.eu-central-1.amazonaws.com/avg-projects/stylegan_xl/models/imagenet512.pkl ... done
Traceback (most recent call last):
  File "run_inversion.py", line 336, in <module>
    run_projection() # pylint: disable=no-value-for-parameter
  File "/home/vibhu/miniconda3/envs/general/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/vibhu/miniconda3/envs/general/lib/python3.7/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/vibhu/miniconda3/envs/general/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/vibhu/miniconda3/envs/general/lib/python3.7/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "run_inversion.py", line 265, in run_projection
    G = legacy.load_network_pkl(fp)['G_ema'].to(device) # type: ignore
  File "/home/vibhu/Workspace/stylegan-xl/legacy.py", line 25, in load_network_pkl
    data = _LegacyUnpickler(f).load()
  File "/home/vibhu/Workspace/stylegan-xl/legacy.py", line 75, in find_class
    return super().find_class(module, name)
ModuleNotFoundError: No module named 'timm.models.layers.conv2d_same'

I'd really appreciate any help, thank you.

Liu-Hy commented 1 year ago

This is likely an issue about timm version, when you run the file in another environment. You can try pip install timm==0.4.12. Also, to merge all the requirements specified in a yaml file into an existing conda environment, you can deactivate from the environment and use this conda env update --name myenv --file environment.yml --prune