IndexError: list index out of range
See original GitHub issueI have trained a model without self-critical, and run eval.py, an error occurs:
File "/host/xx/self-critical/eval_utils.py", line 143, in eval_split
lang_stats = language_eval(dataset, predictions, eval_kwargs['id'], split)
File "/host/xx/self-critical/eval_utils.py", line 39, in language_eval
cocoRes = coco.loadRes(cache_path)
File "/usr/local/lib/python3.5/dist-packages/pycocotools/coco.py", line 318, in loadRes
if 'caption' in anns[0]:
IndexError: list index out of range
How should I do?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
List Index Out of Range – Python Error Message Solved
You'll get the Indexerror: list index out of range error when iterating through a list and trying to access an item that doesn't...
Read more >Python IndexError: List Index Out of Range Error Explained
Learn how to resolve the Python IndexError, list index out of range, why it occurs in for loops, while loops, and how to...
Read more >Indexerror: list Index Out of Range in Python - STechies
In python “list index out of range” error occurs when we try to access an undefined element from the list. List index out...
Read more >Python IndexError: List Index Out of Range [Easy Fix] - Finxter
The error “list index out of range” arises if you access invalid indices in your ...
Read more >Index Error: list index out of range (Python) - Stack Overflow
Generally it means that you are providing an index for which a list element does not exist. E.g, if your list was [1,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have fixed this problem by change
entry = {'image_id': data['infos'][k]['id'], 'caption': sent}
to
entry = {'image_id': int(data['infos'][k]['file_path'].split('_')[-1].split('.')[0]), 'caption': sent}
in eval_utils.py@ivy94419 Thank you very much ! this help me solve the same problem in repo ruotianluo/ImageCaptioning.pytorch