lightweight-gan
lightweight-gan copied to clipboard
Unable to use "Show Progress"
Summary: Running lightweight_gan --models_dir "path" --show-progress
results in a AttributeError: 'NoneType' object has no attribute 'split'
Full error:
Generating progress images: 0% 0/30 [00:04<?, ?it/s] Traceback (most recent call last): File "/usr/local/bin/lightweight_gan", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/cli.py", line 185, in main fire.Fire(train_from_folder) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 468, in _Fire target=component.__name__) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 672, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/cli.py", line 166, in train_from_folder model.show_progress(num_images=num_image_tiles, types=generate_types) File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 1217, in show_progress generated_image = self.generate_truncated(self.GAN.G, latents) File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 1272, in generate_truncated generated_images = evaluate_in_chunks(self.batch_size, G, style) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 99, in evaluate_in_chunks split_args = list(zip(*list(map(lambda x: x.split(max_batch_size, dim=0), args)))) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 99, in <lambda> split_args = list(zip(*list(map(lambda x: x.split(max_batch_size, dim=0), args)))) AttributeError: 'NoneType' object has no attribute 'split'
I've tried populating all the fields listed in the readme just to check with no luck.
For additional context here's the command used to train the model and generate the checkpoints:
lightweight_gan --num-train-steps 150000 --data /content/images --optimizer "adabelief" --attn-res-layers [32,64,128] --image-size 512 --disc-output-size 5 --models_dir "/LightGAN/" --results_dir "/LightGAN/results" --calculate_fid_every 25000
Try this: lightweight_gan --name name-of-your-model --show-progress --num-image-tiles 4 --generate-types [ema]
Library dont support --models_dir "path"
argument.
Unfortunately no dice. Different error this time though.
Ran: lightweight_gan --name "default" --show-progress --num-image-tiles 4 --generate-types [ema]
Log: Generating progress images: 0it [00:00, ?it/s]Traceback (most recent call last): File "/usr/local/bin/lightweight_gan", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/cli.py", line 185, in main fire.Fire(train_from_folder) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 468, in _Fire target=component.__name__) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 672, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/cli.py", line 166, in train_from_folder model.show_progress(num_images=num_image_tiles, types=generate_types) File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 1208, in show_progress for checkpoint in tqdm(checkpoints, desc='Generating progress images'): File "/usr/local/lib/python3.6/dist-packages/tqdm/std.py", line 1104, in __iter__ for obj in iterable: TypeError: 'NoneType' object is not iterable Generating progress images: 0it [00:00, ?it/s]
Issue arises at line 1208:
https://github.com/lucidrains/lightweight-gan/blob/359c868ec8eddd83b200e31b49f88501cbff674c/lightweight_gan/lightweight_gan.py#L1197-L1210
It looks like checkpoints
(returned at line 1198) is None, as in #48.
You might want to ensure that you are running the latest release of the package.
Currently running the latest (0.17.4). Worth noting that this is running in Colab, not sure why it would cause this but I'd be remiss to not mention this.
Dang it, I was pretty sure I had it there. With models_dir being unsupported here, I figured it was unable to find the checkpoints since it checks ./models/model-name/ but in my environment, the checkpoints are in ./model-name/. Moved the folders around... Now I'm back to the first error.
Generating progress images: 0% 0/32 [00:00<?, ?it/s]Traceback (most recent call last): File "/usr/local/bin/lightweight_gan", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/cli.py", line 185, in main fire.Fire(train_from_folder) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 468, in _Fire target=component.__name__) File "/usr/local/lib/python3.6/dist-packages/fire/core.py", line 672, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/cli.py", line 166, in train_from_folder model.show_progress(num_images=num_image_tiles, types=generate_types) File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 1223, in show_progress generated_image = self.generate_truncated(self.GAN.GE, latents) File "/usr/local/lib/python3.6/dist-packages/torch/autograd/grad_mode.py", line 26, in decorate_context return func(*args, **kwargs) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 1272, in generate_truncated generated_images = evaluate_in_chunks(self.batch_size, G, style) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 99, in evaluate_in_chunks split_args = list(zip(*list(map(lambda x: x.split(max_batch_size, dim=0), args)))) File "/usr/local/lib/python3.6/dist-packages/lightweight_gan/lightweight_gan.py", line 99, in <lambda> split_args = list(zip(*list(map(lambda x: x.split(max_batch_size, dim=0), args)))) AttributeError: 'NoneType' object has no attribute 'split' Generating progress images: 0% 0/32 [00:12<?, ?it/s]
The number of checkpoints is accurate though, so it found the files at least... progress 👍🏾 (Edit: link to Colab for generating progress (I have a separate one that does the training) for additional context https://colab.research.google.com/drive/1H9Mh406f_Bc1ImIGnQObp3H0OXTRDJ08?usp=sharing)
Update: Confirmed issue is present in 0.17.5
Can you show files structure with model checkpoints and usage command?
Heres the file structure for the working directory:
LightGAN/
├── default/
│ ├── .config.json
│ ├── model_1.pt
│ ├── model_10.pt
│ ├── model_11.pt
│ ├── model_12.pt
│ ├── model_13.pt
│ . . .
│ ├── model_45.pt
│ ├── model_5.pt
│ ├── model_6.pt
│ ├── model_7.pt
│ ├── model_8.pt
│ └── model_9.pt
├── generated/
│ └── default/
├── models/
│ └── default/
│ ├── .config.json
│ ├── model_1.pt
│ ├── model_10.pt
│ ├── model_11.pt
│ ├── model_12.pt
│ ├── model_13.pt
│ . . .
│ ├── model_45.pt
│ ├── model_5.pt
│ ├── model_6.pt
│ ├── model_7.pt
│ ├── model_8.pt
│ └── model_9.pt
└── results/
├── default/
│ ├── 0-ema.jpg
│ ├── 0.jpg
│ ├── 1-ema.jpg
│ ├── 1.jpg
│ ├── 10-ema.jpg
│ ├── 10.jpg
│ ├── 11-ema.jpg
│ ├── 11.jpg
│ ├── 12-ema.jpg
│ ├── 12.jpg
│ ├── 13-ema.jpg
│ ├── 13.jpg
│ ├── 14-ema.jpg
│ ├── 14.jpg
│ ├── 15-ema.jpg
│ ├── 15.jpg
│ ├── 16-ema.jpg
│ ├── 16.jpg
│ ├── 17-ema.jpg
│ ├── 17.jpg
│ ├── 18-ema.jpg
│ ├── 18.jpg
│ ├── 19-ema.jpg
│ ├── 19.jpg
│ ├── 2-ema.jpg
│ ├── 2.jpg
│ . . .
│ ├── 59.jpg
│ ├── 6-ema.jpg
│ ├── 6.jpg
│ ├── 60-ema.jpg
│ ├── 60.jpg
│ ├── 61-ema.jpg
│ ├── 61.jpg
│ ├── 7-ema.jpg
│ ├── 7.jpg
│ ├── 8-ema.jpg
│ ├── 8.jpg
│ ├── 9-ema.jpg
│ ├── 9.jpg
│ └── fid_scores.txt
└── default-progress/
Command for generating checkpoints:
lightweight_gan --num-train-steps 150000 --data /content/images --optimizer "adabelief" --attn-res-layers [32,64,128] --image-size 512 --disc-output-size 5 --models_dir "/content/drive/MyDrive/Colab Notebooks/LightGAN" --results_dir "/content/drive/MyDrive/Colab Notebooks/LightGAN/results" --calculate_fid_every 25000
Command for generating progress:
lightweight_gan --name "default" --show-progress --num-image-tiles 4 --generate-types [ema]