-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
PyCharm Printing Numpy Arrays (IndexError: tuple index out of range) #10
Comments
@CF2220160244 I get the same error on printing numpy arrays, but I think in my case this is a PyCharm problem. In PyCharm if I convert the numpy array to a torch tensor labels0 = np.loadtxt(label_path, dtype=np.float32).reshape(-1, 5)
print(labels0)
Traceback (most recent call last):
...
IndexError: tuple index out of range
print(torch.from_numpy(labels0))
tensor([[76.00000, 0.35609, 0.44456, 0.54970, 0.16180],
[ 0.00000, 0.48129, 0.40587, 0.94952, 0.80312]]) In Spyder the same operation shows no errors: ipdb> labels0 = np.loadtxt(label_path, dtype=np.float32).reshape(-1, 5)
ipdb> labels0
array([[76. , 0.356086, 0.444563, 0.549703, 0.161803],
[ 0. , 0.481289, 0.405874, 0.949516, 0.803123]], dtype=float32)
ipdb> print(labels0)
[[76. 0.356086 0.444563 0.549703 0.161803]
[ 0. 0.481289 0.405874 0.949516 0.803123]] |
The issue seem to be that the print option for float_kind has a typo (https://github.com/ultralytics/yolov3/blob/master/utils/utils.py#L10). |
@NaumanKhan665
sudo rm -rf yolov3 # remove exising repo
git clone https://github.com/ultralytics/yolov3 && cd yolov3 # git clone latest
python3 detect.py # verify detection
python3 train.py # verify training (a few batches only)
# CODE TO REPRODUCE YOUR ISSUE HERE
If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you! |
when i print (labels) in datasets.py ,row 143, there are a problem:
i can not print (lables), but i can print (labels[0][0]), print(labels0.shape)
Load labels
#############
Traceback (most recent call last):
File "train.py", line 193, in
main(opt)
File "train.py", line 116, in main
for i, (imgs, targets) in enumerate(dataloader):
File "/home/chenfei/Downloads/yolov3-master1/utils/datasets.py", line 143, in next
print(labels)
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 1504, in array_str
return array2string(a, max_line_width, precision, suppress_small, ' ', "")
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 668, in array2string
return _array2string(a, options, separator, prefix)
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 460, in wrapper
return f(self, *args, **kwargs)
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 495, in _array2string
summary_insert, options['legacy'])
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 796, in _formatArray
curr_width=line_width)
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 750, in recurser
word = recurser(index + (-i,), next_hanging_indent, next_width)
File "/home/chenfei/anaconda3/lib/python3.6/site-packages/numpy/core/arrayprint.py", line 704, in recurser
return format_function(a[index])
IndexError: tuple index out of range
The text was updated successfully, but these errors were encountered: