facebookresearch / pytorch_GAN_zoo

A mix of GAN implementations including progressive growing
BSD 3-Clause "New" or "Revised" License
1.62k stars 271 forks source link

How to generate images per class? #92

Closed ivder closed 4 years ago

ivder commented 4 years ago

When I run eval.py it will generate 32x8 images as expected. But the 1 big image consists images from all classes If I run: python3 eval.py visualization -n animal -m PGAN --Class dog

It will produce: eval.py: error: unrecognized arguments: --Class dog I don't think there's a --Class flag in eval.py

How to use conditional GAN or generate the 1 big image for 1 class each? Thank you

Molugan commented 4 years ago

Hi,

Sorry for the delay ! It seems indeed that the doc could be clearer To see the available labels on a model launch: python eval.py visualization -n animal -m PGAN --showLabels

Then you should see the name of the different categories and their labels appear.

Then run python eval.py visualization -n animal -m PGAN --$MY_CATEGORY $MY_LABEL

In you case I guess it should be: python eval.py visualization -n animal -m PGAN --Main dog

Molugan commented 4 years ago

https://github.com/facebookresearch/pytorch_GAN_zoo/pull/96

ivder commented 4 years ago

@Molugan Thank you for the clarification

JanineCHEN commented 4 years ago

Hi @Molugan , thank you for this great repo, I have trained the stylegan using my own dataset and trying to output some samples by running the eval.py. I can do normal visualization using either python eval.py visualization -n stylegan_outdoor -m StyleGAN or python eval.py visualization -n stylegan_outdoor -m StyleGAN --save_dataset fake_data_outdoor, yet I cannot do conditional generation, when I run `python eval.py visualization -n stylegan_outdoor -m StyleGAN --Main Houses' I got error:

Traceback (most recent call last):
  File "eval.py", line 54, in <module>
    out = module.test(parser, visualisation=vis_module)
  File "/models/eval/visualization.py", line 114, in test
    16, toPlot, env=name + "_pictures")
  File "/models/gan_visualizer.py", line 178, in generateImagesFomConstraints
    outImg = self.model.test(input, getAvG=True)
  File "/models/base_GAN.py", line 136, in test
    return self.avgG(input).cpu()
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/parallel/data_parallel.py", line 153, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/models/networks/styleGAN.py", line 156, in forward
    mapping = self.mapping(self.noramlizationLayer(x))
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/models/networks/styleGAN.py", line 62, in forward
    x = self.activation(layer(x))
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/models/networks/custom_layers.py", line 72, in forward
    x = self.module(x)
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 87, in forward
    return F.linear(input, self.weight, self.bias)
  File "/.virtualenvs/cv/lib/python3.6/site-packages/torch/nn/functional.py", line 1612, in linear
    output = input.matmul(weight.t())
RuntimeError: size mismatch, m1: [10752 x 1], m2: [672 x 512] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:283

Any insights on this issue? Any help would be greatly appreciated!