question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"IndexError: list index out of range" when evaluating

See original GitHub issue

Hi, guys, I got this error when evaluating my model, the command I use is like this,

python tools/voc_eval.py results.pkl configs/test_faster_rcnn_r50_fpn_1x_voc0712.py

And the error information is

Traceback (most recent call last):
  File "tools/voc_eval.py", line 51, in <module>
    main()
  File "tools/voc_eval.py", line 47, in main
    voc_eval(args.result, test_dataset, args.iou_thr, args.nproc)
  File "tools/voc_eval.py", line 26, in voc_eval
    nproc=nproc)
  File "/home/songyuc/professional/船舶目标检测/模型测试/mmdetection/mmdetection/mmdet/core/evaluation/mean_ap.py", line 388, in eval_map
    mean_ap, eval_results, dataset, area_ranges, logger=logger)
  File "/home/songyuc/professional/船舶目标检测/模型测试/mmdetection/mmdetection/mmdet/core/evaluation/mean_ap.py", line 464, in summary
    label_names[j], num_gts[i, j], results[j]['num_dets'],
IndexError: list index out of range

I have created my own dataset as,

from .coco import CocoDataset
from .registry import DATASETS

from .voc import VOCDataset

@DATASETS.register_module
class MyDataset(VOCDataset):
    CLASSES = (
        'helicopter', 'c130', 'b2', 'other', 'b52', 'kc10', 'c17', 'command', 'c5', 'f15', 'kc135', 'a10', 'b1', 'aew',
        'p3', 'f16', 'p8', 'f35', 'f18', 'v22', 'f4', 'f22', 'globalhawk', 'u2'
    )
  1. What dataset did you use? I use my own dataset in VOC format.

Environment

  1. Please run python tools/collect_env.py to collect necessary environment infomation and paste it here.
sys.platform: linux
Python: 3.7.4 (default, Aug 13 2019, 20:35:49) [GCC 7.3.0]
CUDA available: True
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 10.1, V10.1.243
GPU 0: GeForce RTX 2080 Ti
GCC: gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
PyTorch: 1.3.1
PyTorch compiling details: PyTorch built with:
  - GCC 7.3
  - Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v0.20.5 (Git Hash 0125f28c61c1f822fd48570b4c1066f96fcb9b2e)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - NNPACK is enabled
  - CUDA Runtime 10.1
  - NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_37,code=compute_37
  - CuDNN 7.6.3
  - Magma 2.5.1
  - Build settings: BLAS=MKL, BUILD_NAMEDTENSOR=OFF, BUILD_TYPE=Release, CXX_FLAGS= -Wno-deprecated -fvisibility-inlines-hidden -fopenmp -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -O2 -fPIC -Wno-narrowing -Wall -Wextra -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Wno-stringop-overflow, DISABLE_NUMA=1, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, USE_CUDA=True, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_STATIC_DISPATCH=OFF, 

TorchVision: 0.4.2
OpenCV: 4.1.1
MMCV: 0.2.15
MMDetection: 1.0rc1+e907139
MMDetection Compiler: GCC 7.4
MMDetection CUDA Compiler: 10.1
  1. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source] By Conda commands.

Error traceback If applicable, paste the error trackback here.

Traceback (most recent call last):
  File "tools/voc_eval.py", line 51, in <module>
    main()
  File "tools/voc_eval.py", line 47, in main
    voc_eval(args.result, test_dataset, args.iou_thr, args.nproc)
  File "tools/voc_eval.py", line 26, in voc_eval
    nproc=nproc)
  File "/home/songyuc/professional/船舶目标检测/模型测试/mmdetection/mmdetection/mmdet/core/evaluation/mean_ap.py", line 388, in eval_map
    mean_ap, eval_results, dataset, area_ranges, logger=logger)
  File "/home/songyuc/professional/船舶目标检测/模型测试/mmdetection/mmdetection/mmdet/core/evaluation/mean_ap.py", line 464, in summary
    label_names[j], num_gts[i, j], results[j]['num_dets'],
IndexError: list index out of range

Bug fix If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hellockcommented, Jan 11, 2020

You may need to debug and see which list causes list index out of range.

1reaction
hellockcommented, Jan 9, 2020

Is this issue still valid?

Read more comments on GitHub >

github_iconTop 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 [Easy Fix] - Finxter
What is this? The error “list index out of range” arises if you access invalid indices in your Python list. For example, if...
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 Solution
The Problem: indexerror: list index out of range. This error message tells us that we're trying to access a value inside an array...
Read more >
Python IndexError: List Index Out of Range Error Explained
What is the Python IndexError? ... We can break down the text a little bit. We can see here that the message tells...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found