f90 / FactorGAN

FactorGAN - Training GANs with missing data
MIT License
35 stars 3 forks source link

From issue #1: Testing the final model #4

Closed f90 closed 4 years ago

f90 commented 4 years ago

From issue #1: @kalai2033 asks: How to test the final model... I'm using the following code to train:

!python Image2Image.py --cuda --batchSize=10 --loadSize 256 --dataset "diff" --num_joint_samples 300 --factorGAN 1 --experiment_name "diff"

f90 commented 4 years ago

@kalai2033 The final model is automatically tested at the end of training. You can also evaluate a previously trained model (skipping the training phase) by passing --eval as an additional parameter when running the Python script. Hope that answers your question?

kalai2033 commented 4 years ago

I get this error when i use the --eval flag for testing.

!python Image2Image.py --cuda --batchSize=2 --loadSize 256 --dataset "diff" --factorGAN 1 --eval --experiment_name "diff"

Namespace(L2=0.0, batchSize=2, beta1=0.5, cuda=True, dataset='diff', disc_iter=2, epoch_iter=5000, epochs=40, eval=True, eval_model='G', experiment_name='diff', factorGAN=1, generator_channels=32, lipschitz_p=1, lipschitz_q=1, loadSize=256, lr=0.0001, num_joint_samples=1000, nz=50, objective='JSD', out_path='out', seed=1337, use_real_dep_disc=1, workers=1) Random Seed: 1337 dataset [AlignedDataset] was created Traceback (most recent call last): File "/home/kalai/exp/FactorGAN/datasets/InfiniteDataSampler.py", line 19, in next data = next(self.data_iter) File "/home/kalai/anaconda3/envs/new/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in next data = self._next_data() File "/home/kalai/anaconda3/envs/new/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 831, in _next_data raise StopIteration StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "Image2Image.py", line 172, in eval(opt) File "Image2Image.py", line 126, in eval generate_images(G, G_inputs, opt.gen_path, 100, device, lambda x : Utils.create_image_pair(x, dataset.A_nc, dataset.B_nc)) File "/home/kalai/exp/FactorGAN/eval/Visualisation.py", line 12, in generate_images gen_input = next(generator_inputs) File "/home/kalai/exp/FactorGAN/datasets/InfiniteDataSampler.py", line 24, in next data = next(self.data_iter) File "/home/kalai/anaconda3/envs/new/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in next data = self._next_data() File "/home/kalai/anaconda3/envs/new/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 831, in _next_data raise StopIteration StopIteration

f90 commented 4 years ago

You pass a non-supported value for the "dataset" parameter into your model (namely "diff") - we only support cityscapes and edges2shoes at the moment. Something seems wrong with your dataset - it couldn't be loaded or doesn't have enough samples, that's why during batch creation the data loader fails immediately when trying to create the first batch.

Check your setup while using cityscapes or edges2shoes dataset, you will probably find that there will not be such an error occuring. Then you know you have to correct how you are loading your particular dataset. I cannot really help you much with that since I don't know your particular dataset!

kalai2033 commented 4 years ago

@f90 Thanks. I have changed the directory structure similar to the cityscapes dataset. It seems it is using the images from the validation folder. Now i can see the test results in the out directory.

kalai2033 commented 4 years ago

I am getting 256x256 image as output even i pass 600x400 image as input. How can i change the test script to prduce output image similar to original image shape?