-
Notifications
You must be signed in to change notification settings - Fork 574
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
IndexError: index 1 is out of bounds for axis 0 with size 0 #1072
Comments
i print the result of the image, the images is 0,but something other is correct:
the result is,my pciture is no bad: |
You can try to update the newest version of mmrotate, then the problem may be solved. |
Prerequisite
Task
I have modified the scripts/configs, or I'm working on my own tasks/models/datasets.
Branch
master branch https://github.com/open-mmlab/mmrotate
Environment
_libgcc_mutex 0.1 main
_openmp_mutex 5.1 1_gnu
addict 2.4.0 pypi_0 pypi
aliyun-python-sdk-core 2.15.2 pypi_0 pypi
aliyun-python-sdk-kms 2.16.5 pypi_0 pypi
ca-certificates 2024.7.2 h06a4308_0
certifi 2024.8.30 pypi_0 pypi
cffi 1.17.1 pypi_0 pypi
charset-normalizer 3.3.2 pypi_0 pypi
click 8.1.7 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
crcmod 1.7 pypi_0 pypi
cryptography 43.0.1 pypi_0 pypi
cycler 0.12.1 pypi_0 pypi
e2cnn 0.2.3 pypi_0 pypi
filelock 3.14.0 pypi_0 pypi
fonttools 4.54.1 pypi_0 pypi
idna 3.10 pypi_0 pypi
importlib-metadata 8.5.0 pypi_0 pypi
jmespath 0.10.0 pypi_0 pypi
kiwisolver 1.4.7 pypi_0 pypi
ld_impl_linux-64 2.38 h1181459_1
libffi 3.4.4 h6a678d5_1
libgcc-ng 11.2.0 h1234567_1
libgomp 11.2.0 h1234567_1
libstdcxx-ng 11.2.0 h1234567_1
markdown 3.7 pypi_0 pypi
markdown-it-py 3.0.0 pypi_0 pypi
matplotlib 3.5.3 pypi_0 pypi
mdurl 0.1.2 pypi_0 pypi
mmcv-full 1.7.2 pypi_0 pypi
mmdet 2.28.2 pypi_0 pypi
mmrotate 0.3.4 dev_0
model-index 0.1.11 pypi_0 pypi
mpmath 1.3.0 pypi_0 pypi
ncurses 6.4 h6a678d5_0
numpy 1.24.4 pypi_0 pypi
opencv-python 4.10.0.84 pypi_0 pypi
opendatalab 0.0.10 pypi_0 pypi
openmim 0.3.9 pypi_0 pypi
openssl 3.0.15 h5eee18b_0
openxlab 0.1.1 pypi_0 pypi
ordered-set 4.1.0 pypi_0 pypi
oss2 2.17.0 pypi_0 pypi
packaging 24.1 pypi_0 pypi
pandas 2.0.3 pypi_0 pypi
pillow 10.4.0 pypi_0 pypi
pip 24.2 py38h06a4308_0
platformdirs 4.3.6 pypi_0 pypi
pycocotools 2.0.7 pypi_0 pypi
pycparser 2.22 pypi_0 pypi
pycryptodome 3.20.0 pypi_0 pypi
pygments 2.18.0 pypi_0 pypi
pyparsing 3.1.4 pypi_0 pypi
python 3.8.19 h955ad1f_0
python-dateutil 2.9.0.post0 pypi_0 pypi
pytz 2023.4 pypi_0 pypi
pyyaml 6.0.2 pypi_0 pypi
readline 8.2 h5eee18b_0
requests 2.28.2 pypi_0 pypi
rich 13.4.2 pypi_0 pypi
scipy 1.10.1 pypi_0 pypi
setuptools 60.2.0 pypi_0 pypi
six 1.16.0 pypi_0 pypi
sqlite 3.45.3 h5eee18b_0
sympy 1.13.3 pypi_0 pypi
tabulate 0.9.0 pypi_0 pypi
terminaltables 3.1.10 pypi_0 pypi
tk 8.6.14 h39e8969_0
tomli 2.0.1 pypi_0 pypi
torch 1.8.0+cu111 pypi_0 pypi
torchaudio 0.8.0 pypi_0 pypi
torchvision 0.9.0+cu111 pypi_0 pypi
tqdm 4.65.2 pypi_0 pypi
typing-extensions 4.12.2 pypi_0 pypi
tzdata 2024.2 pypi_0 pypi
urllib3 1.26.20 pypi_0 pypi
wheel 0.44.0 py38h06a4308_0
xz 5.4.6 h5eee18b_1
yapf 0.40.2 pypi_0 pypi
zipp 3.20.2 pypi_0 pypi
zlib 1.2.13 h5eee18b_1
Reproduces the problem - code sample
I run this command: python tools/train.py /media/newmy/code_env/mmrotate-main/configs/rotated_retinanet/rotated_retinanet_hbb_r50_fpn_1x_dota_le90.py
1.the dota.py
class DOTADataset(CustomDataset):
"""DOTA dataset for detection.
2.the dotav1.py
dataset settings
dataset_type = 'DOTADataset'
data_root = '/media/newmy/code_env/mmrotate-main/data/split_1024_dota1_0/'
data_root = '/media/newmy/code_env/mmrotate-main/data/split_1024_dota1_0/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(type='RResize', img_scale=(1024, 1024)),
dict(type='RRandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels'])
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(1024, 1024),
flip=False,
transforms=[
dict(type='RResize'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img'])
])
]
data = dict(
samples_per_gpu=1,
workers_per_gpu=0,
train=dict(
type=dataset_type,
ann_file=data_root + 'train/annfiles',
img_prefix=data_root + 'train/images',
# ann_file=data_root + 'train/labelTxt-v1.0/labelTxt/',
# img_prefix=data_root + 'train/images/',
pipeline=train_pipeline),
val=dict(
type=dataset_type,
ann_file=data_root + 'val/annfiles',
img_prefix=data_root + 'val/images',
# ann_file=data_root + 'val/labelTxt-v1.0/labelTxt/',
# img_prefix=data_root + 'val/images/',
pipeline=test_pipeline),
test=dict(
type=dataset_type,
ann_file=data_root + 'test/annfiles',
img_prefix=data_root + 'test/images',
# ann_file=data_root + 'test/part1/images/',
# img_prefix=data_root + 'test/part2/images',
pipeline=test_pipeline))
i chang the num_classes=4, other is not change
Reproduces the problem - command or script
python tools/train.py /media/newmy/code_env/mmrotate-main/configs/rotated_retinanet/rotated_retinanet_hbb_r50_fpn_1x_dota_le90.py
Reproduces the problem - error message
1.Traceback (most recent call last):
File "tools/train.py", line 194, in
main()
File "tools/train.py", line 183, in main
train_detector(
File "/media/newmy/code_env/mmrotate-main/mmrotate/apis/train.py", line 144, in train_detector
runner.run(data_loaders, cfg.workflow)
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 136, in run
epoch_runner(data_loaders[i], **kwargs)
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmcv/runner/epoch_based_runner.py", line 49, in train
for i, data_batch in enumerate(self.data_loader):
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 517, in next
data = self._next_data()
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmdet/datasets/custom.py", line 220, in getitem
data = self.prepare_train_img(idx)
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmdet/datasets/custom.py", line 243, in prepare_train_img
return self.pipeline(results)
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmdet/datasets/pipelines/compose.py", line 41, in call
data = t(data)
File "/home/lixinru/anaconda3/envs/mmrotate/lib/python3.8/site-packages/mmdet/datasets/pipelines/transforms.py", line 472, in call
results[key] = self.bbox_flip(results[key],
File "/media/newmy/code_env/mmrotate-main/mmrotate/datasets/pipelines/transforms.py", line 89, in bbox_flip
flipped[:4] = flipped[[1, 0, 3, 2]].copy()
IndexError: index 1 is out of bounds for axis 0 with size 0
i debug this code,find that this bboxs is null,i didn't known why?,print the bboxs is [ ],but i print the dotav1.py :
def bbox_flip(self, bboxes, img_shape, direction):
"""Flip bboxes horizontally or vertically.
3.but i print the dota.py ,it canbe print the annotation:
def load_annotations(self, ann_folder):
"""
Args:
ann_folder: folder that contains DOTA v1 annotations txt files
"""
cls_map = {c: i
for i, c in enumerate(self.CLASSES)
} # in mmdet v2.0 label is 0-based
ann_files = glob.glob(ann_folder + '/*.txt')
Additional information
the dataset annotation i use is just like:
242 231 253 208 312 236 301 258 Car 0
186 209 195 187 250 208 242 231 Car 0
468 417 477 396 536 419 527 440 Car 0
68 545 75 522 124 539 116 561 Truck 0
63 487 75 463 138 494 126 518 Truck 0
453 226 460 204 513 224 505 245 Car 0
i check the anno ,it is correct


mmrotate-main/data/split_1024_dota1_0:
train/val/test: each have annfiles (the file is include txt file) and images (the file is include png pictures)
The text was updated successfully, but these errors were encountered: