luxonis / depthai-ml-training

Some Example Neural Models that we've trained along with the training scripts
MIT License
118 stars 32 forks source link

YoloV7 Training Colab Error: AttributeError: module 'numpy' has no attribute 'int'` #35

Closed YXGuan closed 1 year ago

YXGuan commented 1 year ago

Attempted to run the YoloV7 training colab without any modification:

https://colab.research.google.com/github/luxonis/depthai-ml-training/blob/master/colab-notebooks/YoloV7_training.ipynb#scrollTo=Z7rEpSboRibz

The first error occurred after running

!python train.py --epochs 2 --workers 8 --device 0 --batch-size 32 --data data/voc.yaml --img 640 640 --cfg cfg/training/yolov7_voc-tiny.yaml --weights 'yolov7-tiny.pt' --hyp data/hyp.scratch.tiny.yaml
/usr/local/lib/python3.8/dist-packages/torch/functional.py:504: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at ../aten/src/ATen/native/TensorShape.cpp:3190.)
  return _VF.meshgrid(tensors, **kwargs)  # type: ignore[attr-defined]
Model Summary: 263 layers, 6066402 parameters, 6066402 gradients, 13.3 GFLOPS

Transferred 330/344 items from yolov7-tiny.pt
Scaled weight_decay = 0.0005
Optimizer groups: 58 .bias, 58 conv.weight, 61 other
train: Scanning 'VOCdevkit/voc_07_12/labels/train.cache' images and labels... 16551 found, 0 missing, 0 empty, 0 corrupted: 100% 16551/16551 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "train.py", line 616, in <module>
    train(hyp, opt, device, tb_writer)
  File "train.py", line 245, in train
    dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt,
  File "/content/yolov7/utils/datasets.py", line 69, in create_dataloader
    dataset = LoadImagesAndLabels(path, imgsz, batch_size,
  File "/content/yolov7/utils/datasets.py", line 418, in __init__
    bi = np.floor(np.arange(n) / batch_size).astype(np.int)  # batch index
  File "/usr/local/lib/python3.8/dist-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'int'

image

Your help would be much appreciated!

Happy new year and holidays!

YXGuan commented 1 year ago

curl api.roboflow.com curlRoboFlow1 curlRoboFlow2Error

dhartness commented 1 year ago

I had to edit the install string in several areas to account for the changing dependencies.

This was for the YOLOv6n training Colab page but it may help you.

I had to specify numpy==1.23.1.

My full updated install string is (currently ;) ):

!pip install -U -q torch==1.13.0 torchvision>=0.9.0 protobuf==3.19.5 numpy==1.23.1 opencv-python>=4.1.2 PyYAML>=5.3.1 scipy>=1.4.1 tqdm>=4.41.0 addict>=2.4.0 tensorboard==2.9.0 pycocotools>=2.0 onnx>=1.10.0 onnx-simplifier>=0.3.6 thop

YXGuan commented 1 year ago

I had to edit the install string in several areas to account for the changing dependencies.

This was for the YOLOv6n training Colab page but it may help you.

I had to specify numpy==1.23.1.

My full updated install string is (currently ;) ):

!pip install -U -q torch==1.13.0 torchvision>=0.9.0 protobuf==3.19.5 numpy==1.23.1 opencv-python>=4.1.2 PyYAML>=5.3.1 scipy>=1.4.1 tqdm>=4.41.0 addict>=2.4.0 tensorboard==2.9.0 pycocotools>=2.0 onnx>=1.10.0 onnx-simplifier>=0.3.6 thop

It works thank you very much Deon!