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

Exception: index 1000 is out of bounds for axis 0 with size 1000 #99

Open
ahmedqasem opened this issue Nov 12, 2020 · 11 comments
Open

Exception: index 1000 is out of bounds for axis 0 with size 1000 #99

ahmedqasem opened this issue Nov 12, 2020 · 11 comments

Comments

@ahmedqasem
Copy link

ahmedqasem commented Nov 12, 2020

I am getting the following exception when I run the train_frcnn.py file, when the model finishes running the epochs it goes into an infinite loop printing out the same exception

1000/1000 [==============================] - 592s - rpn_cls: 0.0000e+00 - rpn_regr: 0.0000e+00 - detector_cls: 0.0000e+00 - detector_regr: 0.0000e+00
Exception: name 'mean_overlapping_boxes' is not defined
Average number of overlapping bounding boxes from RPN = 56.069 for 1000 previous iterations
Exception: index 1000 is out of bounds for axis 0 with size 10001

I use the following command to run the train_frcnn.py
python train_frcnn.py -o simple -p annotate2.txt --num_epochs=1

I traced back the error to line 243 in train_rcnn.py:

losses[iter_num, 0] = loss_rpn[1]
losses[iter_num, 1] = loss_rpn[2]

losses[iter_num, 2] = loss_class[1]
losses[iter_num, 3] = loss_class[2]
losses[iter_num, 4] = loss_class[3]

did anyone get the same exception or know what is the issue?

this is my first time posting a question so I apologize if i didnt provide much details, please let me know what I missed

@ahmedqasem
Copy link
Author

I solved this, it was a version compatibility issue.

@liujs1016
Copy link

I got the same problem.

@ahmedqasem
Copy link
Author

I solved it by using tensorflow 1.15 and keras 2.2.4

@liujs1016
Copy link

liujs1016 commented Nov 30, 2020

My environment is tensorflow 1.15 and keras 2.3.1
I downgrade keras version(2.1.6 & 2.2.4 & 2.2.5) but it got the error.
Exception: index 1000 is out of bounds for axis 0 with size 1000

@ahmedqasem ahmedqasem reopened this Nov 30, 2020
@ahmedqasem
Copy link
Author

I realized it was a version compatibility when it was working on some environments and not others. after some googling i realized that I had to use the specific Keras version that is compatible with the installed tensorflow version, and since the original repo does not mention anything about the environment i did some experimenting.

what worked for me was using Colab with TF 1.15.2 and Keras 2.2.4, so basically since its TF 1.x you should use the compatible Keras version, to know which Keras is compatible, install TF and run the following code:

import tensorflow as tf
print(tf.VERSION)
print(tf.keras.__version__)

the output will be your current TF version and what Keras version you should install. in case you are on Colab switch to TF 1.x by running:

%tensorflow_version 1.x

and then install Keras by running the code below, just keep in mind that you may have to run this twice as sometimes it doesn't install it on the first try (i have no idea why lol)

!pip install q keras==2.2.4

then it doesn't hurt to double check your installations one more time

import tensorflow as tf 
import keras 
print(tf.__version__)
print(keras.__version__)

@liujs1016
Copy link

Ok, I will try again and see if there is any progress I will let you know.
Thanks a lot !

@ShikharGhimire
Copy link

Did you find any solution?Mine still says the same even if I changed the keras and tensorflow version

@dbarrientosg
Copy link

Did you find any solution?Mine still says the same even if I changed the keras and tensorflow version

I solved this error. The error happens because it miss a "b" in the line 263. So line 274 wont be executed and iter_num wont be set to 0. This provocate the error "index 1000 is out of bounds for axis 0 with size 10001" in the line 243 when the loop start again.

The correct line of code is for line 263 is:

print(f'Mean number of bounding boxes from RPN overlapping ground truth boxes: {mean_overlapping_bboxes}')

@ShikharGhimire
Copy link

Did you find any solution?Mine still says the same even if I changed the keras and tensorflow version

I solved this error. The error happens because it miss a "b" in the line 263. So line 274 wont be executed and iter_num wont be set to 0. This provocate the error "index 1000 is out of bounds for axis 0 with size 10001" in the line 243 when the loop start again.

The correct line of code is for line 263 is:

print(f'Mean number of bounding boxes from RPN overlapping ground truth boxes: {mean_overlapping_bboxes}')

Thank you but can you tell me on which file I should edit this?

@dbarrientosg
Copy link

Did you find any solution?Mine still says the same even if I changed the keras and tensorflow version

I solved this error. The error happens because it miss a "b" in the line 263. So line 274 wont be executed and iter_num wont be set to 0. This provocate the error "index 1000 is out of bounds for axis 0 with size 10001" in the line 243 when the loop start again.
The correct line of code is for line 263 is:
print(f'Mean number of bounding boxes from RPN overlapping ground truth boxes: {mean_overlapping_bboxes}')

Thank you but can you tell me on which file I should edit this?

train_rcnn.py

@succode
Copy link

succode commented Jul 30, 2021

try to # if C.verbose:

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

5 participants