minar09 / ACGPN

"Towards Photo-Realistic Virtual Try-On by Adaptively Generating↔Preserving Image Content",CVPR 2020. (Modified from original with fixes for inference)
https://github.com/switchablenorms/DeepFashion_Try_On
77 stars 70 forks source link

ModuleAttributeError: 'Pix2PixHDModel' object has no attribute 'module' #5

Open daxjain789 opened 4 years ago

daxjain789 commented 4 years ago

I have searched the entire repo but still couldn't find the solution for the above error. Any solution for this ? File "train.py", line 168, in <module> loss_dict = dict(zip(model.module.loss_names, losses)) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 772, in __getattr__ type(self).__name__, name)) torch.nn.modules.module.ModuleAttributeError: 'Pix2PixHDModel' object has no attribute 'module'

minar09 commented 4 years ago

@daxjain789 , I didn't check the train.py in this repository, only ran the test.py, hence I am not sure what's causing it. You may refer to the original repository of acgpn for the train scripts.

joel1895 commented 4 years ago

This will solve the issue, after model.initialize(), add the below code .Here,the model is wrapped around the DataParallel and the 'module' attribute is coming from here. model = torch.nn.DataParallel(model, device_ids=[0]) #0 because of only 1 GPU, add [0,1,2,3] if you have multiple GPUs