encoder4editing icon indicating copy to clipboard operation
encoder4editing copied to clipboard

Inference with sample size >1 fails

Open VisionaryMind opened this issue 2 years ago • 1 comments

This would appear to be a repeat of #60, however, deleting the output directly (or clearing it) does not fix the problem. If option --n_sample is set to any number higher than 1, the following error arises:

Traceback (most recent call last): File "scripts/inference.py", line 133, in main(args) File "scripts/inference.py", line 37, in main generate_inversions(args, generator, latent_codes, is_cars=is_cars) File "/home/visionarymind/anaconda3/envs/e4e_env/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "scripts/inference.py", line 105, in generate_inversions imgs, _ = g([latent_codes[i].unsqueeze(0)], input_is_latent=True, randomize_noise=False, return_latents=True) IndexError: index 1 is out of bounds for dimension 0 with size 1

Deleting the output directory or ensuring there is no pre-existing latents.pt file does not fix the problem. Do you have any idea what the issue could be?

VisionaryMind avatar Apr 30 '22 15:04 VisionaryMind

Hi @VisionaryMind, Sorry for the long response time, haven't had the time to maintain this repo for a while.

In case this is still relevant, I wonder if the images directory you point to contains only a single image, in which case there is only one latent code (index 0) and when you specify n_samples > 1 it fails to find the second latent code (index 1) since there is no such code.

I commited a change relevant to the above, let me know if the problem still persist.

Best, Omer

omertov avatar May 19 '22 15:05 omertov