minar09 / cp-vton-plus

Official implementation for "CP-VTON+: Clothing Shape and Texture Preserving Image-Based Virtual Try-On", CVPRW 2020
https://minar09.github.io/cpvtonplus/
MIT License
346 stars 120 forks source link

Images with different size #32

Open SarahH20 opened 3 years ago

SarahH20 commented 3 years ago

Hi. If I would like to train the model with images at different size (e.g. 288 x 512, which is 1.5 times the current image size (192 x 256)), can I do so? If so, do I need to change any data in the model?

Thanks for your help,

thaithanhtuan commented 3 years ago

You have to change the network architecture to your size. (networks.py) and also the data augmentation.

For fast test, you can resize all input, feed into network, then resize output. For GMM, you can also make use of TPS params (output of regression network), then apply on full images size directly. One problem with resize is losing information (texture) from input.

SarahH20 commented 3 years ago

Thanks @thaithanhtuan for your advice. I'll try to change the data in the networks.py. What do you mean by changing "data augmentation" as well? Thanks again for your help.

thaithanhtuan commented 3 years ago

Sorry, Im wrong. I mean this. image

SarahH20 commented 3 years ago

Thanks @thaithanhtuan Your answer is much appreciated. As I look into the networks.py file, I found 3 places where I need to change so that images with size of 288 x 384 can work with this model. Could you help to review these changes and advise if they're correct and if there're other places in this file that I need to change? Thank you so much for your great help.

CPVTONPlus1 CPVTONPlus2
thaithanhtuan commented 3 years ago

Only change the image input size and image output size, On line 116, Do not change here --> this is the number of channels not image size. If I have time, I will check all the projects, may be we also need to change other files (not only networks.py) Regards,

SarahH20 commented 3 years ago

Thanks @thaithanhtuan

SarahH20 commented 3 years ago

Hi @thaithanhtuan . I just tried training GMM with images of size 384x512 and encountered this error. Do you know why this happened? Thanks for your help as always!


Traceback (most recent call last): File "train.py", line 321, in main() File "train.py", line 292, in main train_gmm(opt, train_loader, model) File "train.py", line 117, in train_gmm grid, refine = model(agnostic, cm, c) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, kwargs) File "/notebooks/networks.py", line 530, in forward theta = self.regression(correlation) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, *kwargs) File "/notebooks/networks.py", line 137, in forward x = self.conv(x) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(input, kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/container.py", line 92, in forward input = module(input) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 343, in forward return self.conv2d_forward(input, self.weight) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 340, in conv2d_forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size 512 192 4 4, expected input[4, 768, 32, 24] to have 192 channels, but got 768 channels instead

SarahH20 commented 3 years ago

Hi @thaithanhtuan . I just tried training GMM with images of size 384x512 and encountered this error. Do you know why this happened? Thanks for your help as always!

Traceback (most recent call last): File "train.py", line 321, in main() File "train.py", line 292, in main train_gmm(opt, train_loader, model) File "train.py", line 117, in train_gmm grid, refine = model(agnostic, cm, c) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, kwargs) File "/notebooks/networks.py", line 530, in forward theta = self.regression(correlation) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, kwargs) File "/notebooks/networks.py", line 137, in forward x = self.conv(x) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call* result = self.forward(input, kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/container.py", line 92, in forward input = module(input) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, **kwargs) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 343, in forward return self.conv2d_forward(input, self.weight) File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/conv.py", line 340, in conv2d_forward self.padding, self.dilation, self.groups) RuntimeError: Given groups=1, weight of size 512 192 4 4, expected input[4, 768, 32, 24] to have 192 channels, but got 768 channels instead

Hi there. Does anyone have any advice on how to fix this issue? Many thanks,

thaithanhtuan commented 3 years ago

image The in put for the regression is based on the output of correlation. Please check by printing out the correlation variable in image Then, change the input_nc in line 513 to that number image

PS: May be in your case, it is 768.

SarahH20 commented 3 years ago

Many thanks. I tried to use 768 for this but faced another error with size mismatch. Any advice on how to fix this?

Screen Shot 2020-11-12 at 7 40 19 pm
thaithanhtuan commented 3 years ago

image At A position, print out the shape of x. (with normal size it is: 64 x 3 x 4 = 768, at B) Then, change the number at B to correct number.

SarahH20 commented 3 years ago

Many thanks