open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.55k stars 9.46k forks source link

list index out of range IndexError #5628

Closed FirasKedidi closed 3 years ago

FirasKedidi commented 3 years ago

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. I have read the FAQ documentation but cannot get the expected help.
  3. The bug has not been fixed in the latest version.

Describe the bug list index out of range

Screenshot from 2021-07-16 14-29-15

Reproduction

  1. What command or script did you run?
python "/home/ranim/Documents/mmdet/mmdetection/tools/test.py" \
          "/home/ranim/Documents/mmdet/models/second_model_conf.py" \
          "/home/ranim/Documents/mmdet/models/second_model_checkpoint.pth" \
              --format-only \
              --options jsonfile_predix="/home/ranim/Documents/mmdet/media.
  1. Did you make any modifications on the code or config? Did you understand what you have modified? I used the coco dataset. I changed the classes and num_classes in the config file

  2. What dataset did you use? Custom dataset Environment

  3. Please run python mmdet/utils/collect_env.py to collect necessary environment information and paste it here.

  4. You may add addition that may be helpful for locating the problem, such as

    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

Error traceback If applicable, paste the error trackback here.

A placeholder for trackback.

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!

KainingYing commented 3 years ago

It seems your len of your inference output is 0. In my situation, the len of results is equal to num_images. Can you show the full log when you execute the code? Maybe you don't inference any image in your test.

FirasKedidi commented 3 years ago

It seems your len of your inference output is 0. In my situation, the len of results is equal to num_images. Can you show the full log when you execute the code? Maybe you don't inference any image in your test.

This is the error log i faced this problem before also when i was working with google colab and i couldn't solve it. I've used inference_detector() function and it worked fine. I think that the inference is done but the problem is in saving the result because the error is the result2json function.

/home/ranim/Documents/mmdet/mmdetection/tools/test.py:101: UserWarning: --options is deprecated in favor of --eval-options warnings.warn('--options is deprecated in favor of --eval-options') loading annotations into memory... Done (t=0.01s) creating index... index created! /home/ranim/Documents/mmdet/mmdetection/mmdet/core/anchor/builder.py:15: UserWarning: ``build_anchor_generator`` would be deprecated soon, please use ``build_prior_generator`` warnings.warn( Use load_from_local loader completed: 0, elapsed: 0sTraceback (most recent call last): File "/home/ranim/Documents/mmdet/mmdetection/tools/test.py", line 237, in <module> main() File "/home/ranim/Documents/mmdet/mmdetection/tools/test.py", line 219, in main dataset.format_results(outputs, **kwargs) File "/home/ranim/Documents/mmdet/mmdetection/mmdet/datasets/coco.py", line 345, in format_results result_files = self.results2json(results, jsonfile_prefix) File "/home/ranim/Documents/mmdet/mmdetection/mmdet/datasets/coco.py", line 276, in results2json if isinstance(results[0],list): IndexError: list index out of range

FirasKedidi commented 3 years ago

It seems your len of your inference output is 0. In my situation, the len of results is equal to num_images. Can you show the full log when you execute the code? Maybe you don't inference any image in your test.

Also forgot to mention the annotation file for the test data is empty it contains only the categories and the test data contains only one image.

FirasKedidi commented 3 years ago

Hello, I just referred to an older question and it turned out that the problem is from the annotation file i only included the categories and not the images: ids and file_names that's why he was giving me the error. Thank you for your help. #5548