[Python] IndexError: index 89 is out of bounds for axis 0 with size 89

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I am getting this error but I don't understand how to solve it, can anyone please help?

    I am trying to run a pre-implemented project on my own text dataset. I am using CUB 200-2011 bird dataset which had initially 11788 birds images and author model has been trained and tested with 11788 images, but for some reason many images were missing when I downloaded the dataset so total I have only 2200 images and 1629 images for training. (you can see in the error as well Model is reading 11788 images filenames from somewhere but found only 1629)

    After running the training file:

    python3 bird_01_pretrain.py

    Namespace(audio_model='Davenet', batch_size=128, cfg_file='cfg/Pretrain/bird_train.yml', data_path='data/birds', exp_dir='', gpu_id=0, image_model='VGG16', img_size=256, lr=0.001, lr_decay=50, manualSeed=200, margin=1.0, momentum=0.9, n_epochs=120, n_print_steps=2, optim='adam', pretrained_image_model=False, resume=True, rnn_type='GRU', save_root='outputs/pre_train/birds', simtype='MISA', tasks='extraction', weight_decay=0.001)

    Total filenames: 11788 001.Black_footed_Albatross/Black_Footed_Albatross_0046_18.jpg

    Load filenames from: data/birds/train/filenames.pickle (1629)

    Traceback (most recent call last):

    File "bird_01_pretrain.py", line 145, in <module>

    dataset = SpeechDataset(cfg.DATA_DIR, 'train',

    File "/opt/app/dataset/datasets_pre.py", line 358, in __init__

    seq_labels[unique_id-1]=i


    IndexError: index 89 is out of bounds for axis 0 with size 89
    ​

    Code:

    # calculate the sequence label for the whole dataset
    if cfg.DATASET_NAME == 'birds'
    if self.split =='train':
    unique_id = np.unique(self.class_id)
    seq_labels = np.zeros(cfg.DATASET_ALL_CLSS_NUM)
    for i in range(cfg.DATASET_TRAIN_CLSS_NUM):
    seq_labels[unique_id-1]=i


    self.labels = seq_labels[np.array(self.class_id)-1]


    I am getting an error at this line: seq_labels[unique_id-1]=i

    datasets_pre.py file has around 400 lines of codes and calling many other modules as well. I would be happy to share if anyone wants to see whole code and other files as well but for now I am trying to give exact piece of code which is causing the error.

    Please help me :)

    I can also provide the author open github repo link if anyone wants to look into deeper.

    Continue reading...

Compartilhe esta Página