Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jacob-kang opened this issue May 3, 2023 · 4 comments

Comments

@jacob-kang
Copy link

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
Copy link

iTomxy commented May 15, 2023

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
Copy link

iTomxy commented May 15, 2023

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
Copy link

iTomxy commented May 15, 2023

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

@jacob-kang
Copy link
Author

jacob-kang commented May 15, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants