universome / stylegan-v

[CVPR 2022] StyleGAN-V: A Continuous Video Generator with the Price, Image Quality and Perks of StyleGAN2
https://universome.github.io/stylegan-v
333 stars 36 forks source link

ImportError: cannot import name 'CoordFuser' from 'src.training.layers' #33

Open jacob-kang opened 1 year ago

jacob-kang commented 1 year ago

Hi. Thanks for your grate wor.

I just run your code with inference (generate.py)

But I got an error which is

" ImportError: cannot import name 'CoordFuser' from 'src.training.layers' "

And I checked the src.training.layers. but there is not CoordFuser. Also no results on searching google CoordFuser.

What is it? and how to fix it?

Thanks.

iTomxy commented 1 year ago

Met the same problem. The error message:

Loading networks from "/home/itom/data3/pretrained/StyleGAN-V/ucf-checkpoint-12k.pkl"...
Traceback (most recent call last):
  File "src/scripts/generate.py", line 150, in <module>
    generate() # pylint: disable=no-value-for-parameter
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "src/scripts/generate.py", line 86, in generate
    G = legacy.load_network_pkl(f)['G_ema'].to(device).eval() # type: ignore
  File "src/legacy.py", line 21, in load_network_pkl
    data = _LegacyUnpickler(f).load()
  File "/home/itom/codes/stylegan-v/src/torch_utils/persistence.py", line 190, in _reconstruct_persistent_obj
    module = _src_to_module(meta.module_src)
  File "/home/itom/codes/stylegan-v/src/torch_utils/persistence.py", line 226, in _src_to_module
    exec(src, module.__dict__) # pylint: disable=exec-used
  File "<string>", line 12, in <module>
ImportError: cannot import name 'CoordFuser' from 'src.training.layers' (/home/itom/codes/stylegan-v/src/training/layers.py)

And I search CoordFuser in the whole project, not found.

Have you solved it?

iTomxy commented 1 year ago

I found CoordFuser in universome/inr-gan/archive/pl-implementation/dinr/modeling/modules/style.py. I copy the related code to this repo, then I get another error:

Loading networks from "/home/itom/data3/pretrained/StyleGAN-V/ucf-checkpoint-12k.pkl"...
Traceback (most recent call last):
  File "src/scripts/generate.py", line 150, in <module>
    generate() # pylint: disable=no-value-for-parameter
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/itom/miniconda3/envs/py37_pt171/lib/python3.7/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "src/scripts/generate.py", line 86, in generate
    G = legacy.load_network_pkl(f)['G_ema'].to(device).eval() # type: ignore
  File "src/legacy.py", line 21, in load_network_pkl
    data = _LegacyUnpickler(f).load()
  File "/home/itom/codes/stylegan-v/src/torch_utils/persistence.py", line 190, in _reconstruct_persistent_obj
    module = _src_to_module(meta.module_src)
  File "/home/itom/codes/stylegan-v/src/torch_utils/persistence.py", line 226, in _src_to_module
    exec(src, module.__dict__) # pylint: disable=exec-used
  File "<string>", line 12, in <module>
ImportError: cannot import name 'construct_time_encoder' from 'src.training.layers' (/home/itom/codes/stylegan-v/src/training/layers.py)

But construct_time_encoder does not exist in universome/inr-gan!

iTomxy commented 1 year ago

These errors occur when using the UCF checkpoint, while the FFS & sky-timelapse checkpoints work well.

jacob-kang commented 1 year ago

@iTomxy No. I haven't. I knew the CoordFuser is in the INR-GAN. And I added the code into styleGAN as well. But It doesn't work. The reason why the error occurs is, I guess, the checkpoint file is not trained by styleGAN.

File "/home/itom/codes/stylegan-v/src/torch_utils/persistence.py", line 226, in _src_to_module exec(src, module.__dict__) # pylint: disable=exec-used the src string contains CoordFuser, But nowhere in styleGAN.