xiezhy6 / PASTA-GAN-plusplus

34 stars 5 forks source link

NameError: name 'os' is not defined #7

Open igor-yusupov opened 1 year ago

igor-yusupov commented 1 year ago

I have an issue "NameError: name 'os' is not defined" while running bash test.sh 1 . The same problem is mentioned here: https://github.com/xiezhy6/PASTA-GAN-plusplus/issues/1#issuecomment-1216112330


  File "test.py", line 192, in <module>
    generate_images() # pylint: disable=no-value-for-parameter
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/conda/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/opt/conda/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "test.py", line 105, in generate_images
    G = legacy.load_network_pkl(f)['G_ema'].to(device) # type: ignore
  File "/PASTA-GAN-plusplus/legacy.py", line 21, in load_network_pkl
    data = _LegacyUnpickler(f).load()
  File "/PASTA-GAN-plusplus/torch_utils/persistence.py", line 190, in _reconstruct_persistent_obj
    module = _src_to_module(meta.module_src)
  File "/PASTA-GAN-plusplus/torch_utils/persistence.py", line 226, in _src_to_module
    exec(src, module.__dict__) # pylint: disable=exec-used
  File "<string>", line 2282, in <module>
NameError: name 'os' is not defined```
nnzhangup commented 1 year ago

Have same question

stereomatchingkiss commented 1 year ago
  1. create a new env, install the package as the readme.md mentioned
  2. add src = "import os\n" + src in the function _src_to_module, this function lie in torch_utils/persistence.py
FatemeZamanian commented 1 year ago
  1. create a new env, install the package as the readme.md mentioned
  2. add src = "import os\n" + src in the function _src_to_module, this function lie in torch_utils/persistence.py

but i got new error: name 'file' is not defined

shrinivasait commented 1 year ago

@FatemeZamanian , did you resolve above error?

shrinivasait commented 1 year ago

@stereomatchingkiss please help us to solve this error.