azadis / MC-GAN

Multi-Content GAN for Few-Shot Font Style Transfer at CVPR 2018
http://bair.berkeley.edu/blog/2018/03/13/mcgan/
Other
445 stars 125 forks source link

Error training with pretrained models. #15

Open Abul22 opened 5 years ago

Abul22 commented 5 years ago

After running ./scripts/train_StackGAN.sh ft37_1

RuntimeError: The size of tensor a (26) must match the size of tensor b (64) at non-singleton dimension 0

... I hackily fixed that changing train.staqckGAN.sh FINESIZE=64 LOADSIZE=64 to FINESIZE=26 LOADSIZE=26

... Then the next error was it couldn't find the files in /A/train/ and /b/train/ (it was looking for ._ft6_14.png when they were all named ft614.png etc (without the ' . ' prepended. So I uploaded them because I couldn't find how that path was being set.

Now I get a similar error to the start..

RuntimeError: The size of tensor a (3) must match the size of tensor b (26) at non-singleton dimension 0

I've given up trying to do this. As it's taken my whole day with no results :(

Here's where I've stopped https://colab.research.google.com/gist/Abul22/cf9a67e393118a1c30add68c38ac65c9/untitled0.ipynb

If anyone else more capable than I could make a working colab (or help me find where I've gone wrong) -- That would be so amazingly great.

Cheers

wxqTS commented 5 years ago

I have faced with same problem. Firstly you shouldn't change the FINESIZE=64 and LOADSIZE=64. It maybe caused by the torchvision, I just changed t_normal_stack = transforms.Compose([ transforms.Normalize(mean,std), ]) to t_normal_stack = transforms.Compose([ transforms.Normalize((0.5,), (0.5,)), ]) in data_loader.py line#36 and solved the problem.

Hope it will help you!

Abul22 commented 5 years ago

Thanks so much for the info and reply.... I tried that and it worked!...but then after a few more hours hammering at it... I'm in too deep again..

Seemingly when self.fake_B0_init.detach() changes..because it loops over a fwe times okay..

weights * self.fake_B0_init.detach()

Traceback (most recent call last): File "train_Stack.py", line 52, in <module> model.optimize_parameters_Stacked(epoch) File "/content/FontTransfer/MC-GAN/models/StackGAN_model.py", line 564, in optimize_parameters_Stacked self.backward_G(fake_B0_grad, iter) File "/content/FontTransfer/MC-GAN/models/StackGAN_model.py", line 421, in backward_G print(weights * self.fake_B0_init.detach()) RuntimeError: The size of tensor a (2) must match the size of tensor b (7) at non-singleton dimension 0

Did you get it running on a colab? Or your own machine...Perhaps that the issue... I had to change some deviceid=gpu[0] etc areas ..but yeh....

Any other insights? Thanks so much for your earlier reply :)

https://github.com/Abul22/MC-GAN

https://colab.research.google.com/drive/19eGY_1J_zwCeRVD_AdfgPvA7UHSmrc-b

wxqTS commented 5 years ago

I didn't meet this problem, perhaps it still the the torchvision problem。。。

RamNewton commented 4 years ago

@Abul22 It's been over a year since this issue popped up. But anyway..

About this issue that you faced

(it was looking for .ft6_14.png when they were all named ft6_14.png etc (without the ' . ' prepended. So I uploaded them because I couldn't find how that path was being set.

The problem here is that all the folders in the public_web_fonts folder have hidden files in them for some reason. So, for all the .png files, there is a corresponding hidden file too. os.walk ends up listing these files too. You have to either manually remove these hidden files or write a hackety solution to avoid reading files that have a '.' prefix in their names