genforce / sefa

[CVPR 2021] Closed-Form Factorization of Latent Semantics in GANs
https://genforce.github.io/sefa/
MIT License
964 stars 108 forks source link

I can't run this scripts #17

Open mxl1990 opened 3 years ago

mxl1990 commented 3 years ago

I run streamlit run interface.py, but I got Error like this Traceback (most recent call last): File "d:\program files\python36\lib\site-packages\streamlit\script_runner.py", line 354, in _run_script exec(code, module.dict) File "D:\code\sefa-master\interface.py", line 129, in main() File "D:\code\sefa-master\interface.py", line 75, in main layers, boundaries, eigen_values = factorize_model(model, layer_idx) File "d:\program files\python36\lib\site-packages\streamlit\caching.py", line 545, in wrapped_func return get_or_create_cached_value() File "d:\program files\python36\lib\site-packages\streamlit\caching.py", line 527, in get_or_create_cached_value return_value = func(*args, **kwargs) File "D:\code\sefa-master\interface.py", line 26, in factorize_model return factorize_weight(model, layer_idx) File "D:\code\sefa-master\utils.py", line 187, in factorize_weight weight = generator.synthesis.getattr(layer_name).style.weight.T AttributeError: 'Parameter' object has no attribute 'T'

I change this code to weight = generator.synthesis.getattr(layer_name).style.weight.t() then, I still got Error like this Traceback (most recent call last): File "d:\program files\python36\lib\site-packages\streamlit\script_runner.py", line 354, in _run_script exec(code, module.dict) File "D:\code\sefa-master\interface.py", line 129, in main() File "D:\code\sefa-master\interface.py", line 124, in main image = synthesize(model, gan_type, code) File "d:\program files\python36\lib\site-packages\streamlit\caching.py", line 545, in wrapped_func return get_or_create_cached_value() File "d:\program files\python36\lib\site-packages\streamlit\caching.py", line 527, in get_or_create_cached_value return_value = func(*args, *kwargs) File "D:\code\sefa-master\interface.py", line 54, in synthesize image = model.synthesis(to_tensor(code))['image'] File "d:\program files\python36\lib\site-packages\torch\nn\modules\module.py", line 493, in call result = self.forward(input, **kwargs) File "D:\code\sefa-master\models\stylegan_generator.py", line 471, in forward if wp.ndim != 3 or wp.shape[1:] != (self.num_layers, self.w_space_dim): AttributeError: 'Tensor' object has no attribute 'ndim'

Is this something wrong with my pytorch vesion or settings?