Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors with custom dataset #165

Open
emoebel opened this issue Mar 24, 2022 · 3 comments
Open

errors with custom dataset #165

emoebel opened this issue Mar 24, 2022 · 3 comments

Comments

@emoebel
Copy link

emoebel commented Mar 24, 2022

Hello, I managed to train with my custom dataset, organised as follows:

A
|-train
|-val
|-test
B
|-train
|-val
|-test
C
|-train
|-val
|-test

With A containing the images, B containing segmentation maps, and C containing instance maps.

Now I am trying to predict. I tried using the instructions from your main github page: python test.py --name [name_of_experiment] --dataset_mode [dataset_mode] --dataroot [path_to_dataset]

But I get the error: test.py: error: the following arguments are required: --label_dir, --image_dir

So I specified the arguments the script was asking for. But I get the error:

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    model = Pix2PixModel(opt)
  File "/net/serpico-fs2/emoebel/increased/semantic_img_synthesis/SPADE/models/pix2pix_model.py", line 25, in __init__
    self.netG, self.netD, self.netE = self.initialize_networks(opt)
  File "/net/serpico-fs2/emoebel/increased/semantic_img_synthesis/SPADE/models/pix2pix_model.py", line 96, in initialize_networks
    netG = util.load_network(netG, 'G', opt.which_epoch, opt)
  File "/net/serpico-fs2/emoebel/increased/semantic_img_synthesis/SPADE/util/util.py", line 208, in load_network
    net.load_state_dict(weights)
  File "/net/serpico-fs2/emoebel/venv/spade/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1483, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for SPADEGenerator:
	size mismatch for fc.weight: copying a param with shape torch.Size([1024, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 14, 3, 3]).
	size mismatch for head_0.norm_0.mlp_shared.0.weight: copying a param with shape torch.Size([128, 3, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 14, 3, 3]).
...

Dear developers, could you please make a tutorial on how to use your code with a custom dataset? (and please test it yourself to make sure it works). It would be nice that this tutorial includes how to organise the data folder. This would be very helpful for everybody. I am sure I am not the only one who wants to test your code with custom data.

@emoebel
Copy link
Author

emoebel commented Mar 24, 2022

Okay so I managed to make it work... I had to randomly test different options
python test.py --name canalB --dataset_mode custom --label_dir datasets/increased/canalB/B/test --image_dir datasets/increased/canalB/A/test --label_nc 3 --no_instance

What is strange, is that for training I used --label_nc 2 but for test I have to put --label_nc 3 else I get an error size mismatch for fc.weight

@emoebel
Copy link
Author

emoebel commented Mar 24, 2022

Another useful information would be: how can I get predictions that have the size and resolution of the original input image? The test procedure outputs images of size 256x256. But I would like the image to have the original size which is 1008x888

@cuberhaus
Copy link

cuberhaus commented Jan 11, 2024

What values did you put in the labels? @emoebel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants