elvisyjlin / AttGAN-PyTorch

AttGAN PyTorch Arbitrary Facial Attribute Editing: Only Change What You Want
MIT License
248 stars 61 forks source link

BUG:TypeError: make_grid() got an unexpected keyword argument 'range' #35

Closed fengfenglong123 closed 8 months ago

fengfenglong123 commented 1 year ago

Hello, I encountered a bug while running this project. Is there any way to solve this bug

Traceback (most recent call last):
  File "train.py", line 188, in <module>
    writer.add_image('sample', vutils.make_grid(samples, nrow=1, normalize=True, range=(-1., 1.)), it+1)
  File "/home/liu/anaconda3/envs/AttGAN/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
TypeError: make_grid() got an unexpected keyword argument 'range'
ghubrakesh commented 1 year ago

In pytorch's recent updates, the make_grid function doesn't take 'range' argument. Either remove the range=(-1., 1.)) argument from the function call, it will take the default values (min, max from the tensor), or you can replace the rangeparameter by value_range your call should look like:
writer.add_image('sample', vutils.make_grid(samples, nrow=1, normalize=True, value_range=(-1, 1)), it+1)

let me know if it works :)

fengfenglong123 commented 1 year ago

Thank you for providing the method. I used the method you mentioned and it worked so well that the model could be trained, but I would like to know how you came up with this modification. In addition, I have a question. When I open the NVIDIA-SMI backend, I see that the usage of graphics memory is only 3G, but I currently have 24GB. I would like to know how to modify it to increase my existing usage.

ghubrakesh commented 1 year ago

Great, I just went through the official documentation of the PyTorch. And about the GPU usage, you can set the application priority higher to get maximum resources allocated to it. Also, you can change the PC power plan to high performance to get the max usage. By default, the application resource allocation depends upon various factors, such as battery saver plan, background processes and application holding up the resources. If you are looking to set an app getting maximum resource allocated to it, refer to some custom methods on YouTube.

fengfenglong123 commented 1 year ago

Okay, thank you for your guidance.

Kerio99 commented 10 months ago

It works, thanks!!!

elvisyjlin commented 8 months ago

Thank @fengfenglong123 for raising up this issue and thank @ghubrakesh for the great solution! I've pushed a fix in https://github.com/elvisyjlin/AttGAN-PyTorch/commit/be2d6c68049eeae4082365738b807aa49d214e77 to close this issue.

littleGabor commented 4 months ago

thank you so much! Love you!!