davidnvq/grit

TypeError: 'NoneType' object does not support item deletion

bai-24 opened this issue · 5 comments

hello,When I train the model, the following error occurs:

File "train_demo.py", line 316, in run_main
main(config)
File "train_demo.py", line 121, in main
dataloaders, samplers = build_coco_dataloaders(config, mode='finetune', device=device)
File "J:\GRIT\datasets\caption\coco.py", line 310, in build_coco_dataloaders
text_field = TextField(vocab_path=config.dataset.vocab_path)
File "J:\GRIT\datasets\caption\field.py", line 137, in init
self.vocab = Vocab(vocab_path=vocab_path)
File "J:\GRIT\datasets\caption\vocab.py", line 70, in init
del counter[tok]
TypeError: 'NoneType' object does not support item deletion

Is there any way to solve it?

I suspect that the vocab_path is wrong in the config file. Please check the valid path of vocab again. If errors still occur, feel free to leave comments here.

Thank you!The issue has been resolved.I used a single machine and single card training model, so the program has been changed a bit.There's a new problem:
Traceback (most recent call last):
File "train_demo.py", line 327, in
run_main()
File "D:\Anaconda3\lib\site-packages\hydra\main.py", line 49, in decorated_main
_run_hydra(
File "D:\Anaconda3\lib\site-packages\hydra_internal\utils.py", line 367, in _run_hydra
run_and_report(
File "D:\Anaconda3\lib\site-packages\hydra_internal\utils.py", line 214, in run_and_report
raise ex
File "D:\Anaconda3\lib\site-packages\hydra_internal\utils.py", line 211, in run_and_report
return func()
File "D:\Anaconda3\lib\site-packages\hydra_internal\utils.py", line 368, in
lambda: hydra.run(
File "D:\Anaconda3\lib\site-packages\hydra_internal\hydra.py", line 110, in run
_ = ret.return_value
File "D:\Anaconda3\lib\site-packages\hydra\core\utils.py", line 233, in return_value
raise self._return_value
File "D:\Anaconda3\lib\site-packages\hydra\core\utils.py", line 160, in run_job
ret.return_value = task_function(task_cfg)
File "train_demo.py", line 320, in run_main
main(config)
File "train_demo.py", line 170, in main
train_res = train_xe(
File "J:\GRIT\engine\caption_engine.py", line 333, in train_xe
for it, batch in enumerate(dataloaders['train']):
File "D:\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 628, in next
data = self._next_data()
File "D:\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py", line 671, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "D:\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "D:\Anaconda3\lib\site-packages\torch\utils\data_utils\fetch.py", line 58, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "J:\GRIT\datasets\caption\coco.py", line 92, in getitem
example = self.examples[idx]
TypeError: list indices must be integers or slices, not tuple

Is there any way to solve it?

Have you resolved the problem yet? It seems that self.examples now becomes a tuple. It is hard for me to know why it leads to this problem if you modified the code for datasets.

Thank you!Can you share how to train object detector on Visual Genome or on 4 datasets? How to divide and store the datasets?

The training of the object detector is somehow out of scope in this Github repo. However, you can track from the previous issues:

  1. #32
  2. #19

If there is any uncertain thing you want to ask, please feel free to open a new issue.