WongKinYiu / yolov7

Implementation of paper - YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
GNU General Public License v3.0
13.37k stars 4.22k forks source link

Issue while training: AttributeError: module 'numpy' has no attribute 'int' #1280

Open Nomlax opened 1 year ago

Nomlax commented 1 year ago
Traceback (most recent call last):
  File "C:\Users\*user*\Desktop\*dataset path*\yolov7-custom\train.py", line 616, in <module>
    train(hyp, opt, device, tb_writer)
  File "C:\Users\*user*\Desktop\*dataset path*\yolov7-custom\train.py", line 245, in train
    dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt,
  File "C:\Users\*user*\Desktop\*dataset path*\yolov7-custom\utils\datasets.py", line 69, in create_dataloader
    dataset = LoadImagesAndLabels(path, imgsz, batch_size,
  File "C:\Users\*user*\Desktop\*dataset path*\yolov7-custom\utils\datasets.py", line 418, in __init__
    bi = np.floor(np.arange(n) / batch_size).astype(np.int)  # batch index
  File "C:\Users\*user*\anaconda3\envs\*venv name*\lib\site-packages\numpy\__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'int'

This happens when I'm trying to train with:

python train.py --workers 0 --device 0 --batch 16 --epochs 10 --img 1280 1280 --data data/data.yaml --cfg cfg/training/yolov7-custom.yaml --weights yolov7-e6e.pt

I'd appreciate any help or guidance

SamSamhuns commented 1 year ago

Check my issue #1273 and the PR fix for it #1272

This happens because you have installed the latest numpy version 1.24.0 where np.int is depreciated. Instead install a lower version of numpy pip install "numpy<1.24.0".

Or you can change the np.int to just int. However, there are still some issues with tensorboard logging with the latest numpy version, so better to downgrade.

Nomlax commented 1 year ago

That's very helpful, thank you! I hope your PR gets merged soon.

SkalskiP commented 1 year ago

@Nomlax Why is that issue closed? No fix have been merged.

Nomlax commented 1 year ago

My bad, I don't know. My mind saw the close button and just pressed it.

SkalskiP commented 1 year ago

No worries @Nomlax :) Thanks for reopening. I'm trying to fix my code for past 2h, and I'm getting slightly annoyed here. I guess I over reacted. One more time, thanks :)

danttis commented 1 year ago

you can create the type that int: np.int = np.int_