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

IndexError: list index out of range #33

Closed
typeface-cn opened this issue Aug 25, 2022 · 4 comments
Closed

IndexError: list index out of range #33

typeface-cn opened this issue Aug 25, 2022 · 4 comments

Comments

@typeface-cn
Copy link

INFO::08/25 20:17:59 | Validation at Epoch = 0.323
Traceback (most recent call last):
  File "D:\lffont\train.py", line 253, in <module>
    main()
  File "D:\lffont\train.py", line 249, in main
    train(args, cfg)
  File "D:\lffont\train.py", line 235, in train
    trainer.train(trn_loader, st_step, cfg[f"{cfg.phase}_iter"])
  File "D:\lffont\trainer\combined_trainer.py", line 173, in train
    self.evaluator.cp_validation(self.gen_ema, self.cv_loaders, self.step, phase="comb",
  File "D:\lffont\evaluator.py", line 44, in cp_validation
    self.comparable_val_saveimg(gen, loader, step, tag=f"comparable_{tag}_{ext_tag}",
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\lffont\evaluator.py", line 19, in decorated
    ret = val_fn(self, gen, *args, **kwargs)
  File "D:\lffont\evaluator.py", line 50, in comparable_val_saveimg
    compare_batches = self.infer_loader(gen, loader, phase=phase, reduction=reduction)
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "D:\lffont\evaluator.py", line 19, in decorated
    ret = val_fn(self, gen, *args, **kwargs)
  File "D:\lffont\evaluator.py", line 60, in infer_loader
    for i, (in_style_ids, in_comp_ids, in_imgs, trg_style_ids, trg_comp_ids,
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 652, in __next__
    data = self._next_data()
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 692, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\ProgramData\Anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "D:\lffont\datasets\p1dataset.py", line 197, in __getitem__
    style_unis, trg_comp_ids = self.sample_char(font_name, trg_uni)
  File "D:\lffont\datasets\p1dataset.py", line 186, in sample_char
    style_uni = random.choice(avail_style_uni)
  File "C:\ProgramData\Anaconda3\lib\random.py", line 346, in choice
    return seq[self._randbelow(len(seq))]
IndexError: list index out of range
@8uos
Copy link
Collaborator

8uos commented Nov 10, 2022

Hi,
It seems that your test dataset does not contain enough source characters to construct the target character.
The model is only available to generate the components in the style characters in phase 1 and so the style characters should contain all the components.
Hence, an error occurs if any component of the target character cannot be found in the source characters.

@SanghyukChun
Copy link
Collaborator

Closing the issue, assuming the answer resolves the problem.
Please re-open the issue as necessary.

@klevin-ken
Copy link

Hi, @typeface-cn how do you solve this problem?

@typeface-cn
Copy link
Author

Hi, @typeface-cn how do you solve this problem?

我没有解决。 I didn't solve it.

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

4 participants