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

ginjinn predict IndexError: list index out of range #4

Open
mareikedaubert opened this issue Mar 24, 2023 · 6 comments
Open

ginjinn predict IndexError: list index out of range #4

mareikedaubert opened this issue Mar 24, 2023 · 6 comments

Comments

@mareikedaubert
Copy link

Hello,
I am receiving an error with ginjinn predict in one of the datasets I am running it one. The error occurs at what is equivalent to the last step of the calculation from the example application "Leucanthemum leaf segmentation" from the docs. I have predicted from a bounding box model and cropped my images to the detected bounding boxes. Then I am predicting from a segmentation model. The prediction step runs to completion, but the refinement and output generation aborts after processing 2% of the data. Accordingly, I have ~1.300 input images, but only 32 images in my output folder.
The error did not occur with another dataset I was working on at the same time and I used the same script on.
The exact error message is:

  File "/user/me/.conda/envs/ginjinn2/lib/python3.7/site-packages/detectron2/utils/visualizer.py", line 241, in _create_text_labels
    labels = [class_names[i] for i in classes]
  File "/user/me/.conda/envs/ginjinn2/lib/python3.7/site-packages/detectron2/utils/visualizer.py", line 241, in <listcomp>
    labels = [class_names[i] for i in classes]
IndexError: list index out of range

What could cause this error to occur?

@mareikedaubert
Copy link
Author

Hello,
I just wanted to add that the error still occurs sporadically for me. The calculation always aborts in the refinement and output generation step after processing a part of the images. It also seems to be independent of the model as I have since implemented both mask_rcnn_X_101_32x8d_FPN_3x.yaml and mask_rcnn_R_101_FPN_3x.yaml.

@ulilautenschlager
Copy link
Member

Hi Mareike,
thanks for reporting this problem. Does ginjinn predict complete if you omit the -v/--visualize option?

@mareikedaubert
Copy link
Author

Hello,
skipping -v avoids the problem. The visualization output is not very essential for me, so I do not mind not having it. I have also tried allocating more RAM to the calculation, but that did not fix it.

@ulilautenschlager
Copy link
Member

It seems in rare cases (e.g. after only short training) categories are predicted which should not exist. (You can verify this in your prediction directory with cat annotations.json | grep category_id | sort | uniq -c.) We need to fix this in the code, for the moment appending the following to your ginjinn_config.yaml (before training) should serve as a workaround:

detectron:
    MODEL:
        ROI_HEADS:
            NUM_CLASSES: <n>

Here, <n> should be replaced by the number of categories, e.g. 1 if you only have a single leaf class.

@mareikedaubert
Copy link
Author

Hello,
Thank you, the workaround worked for me. Would you say it is a sign on insufficient training if this error occurs?

@ulilautenschlager
Copy link
Member

It can be, but not necessarily. On the other hand, a large number of images/objects also makes the error more likely, so I would instead focus on the model performance (AP scores etc.) to decide on the number of training iterations.

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

2 participants