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.24k stars 4.18k forks source link

Custom Object Detection: AttributeError: module 'numpy' has no attribute 'int' #1303

Open croust opened 1 year ago

croust commented 1 year ago

I ran python train.py --workers 1 --device 0 --batch-size 8 --epochs 100 --img 640 640 --data C:\Users\mdari\YOLOv7_Custom\yolov7-custom\data\custom_data.yaml --hyp C:\Users\mdari\YOLOv7_Custom\yolov7-custom\data\hyp.scratch.custom.yaml --cfg C:\Users\mdari\YOLOv7_Custom\yolov7-custom\cfg\training\yolov7-custom.yaml --name yolov7-custom --weights yolov7.pt

and got the following error.

C:\Users\mdari\miniconda3\envs\yolov7_custom\lib\site-packages\torch\functional.py:568: UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\actions-runner_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\TensorShape.cpp:2228.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined] Model Summary: 415 layers, 37196556 parameters, 37196556 gradients, 105.1 GFLOPS

Transferred 552/566 items from yolov7.pt Scaled weight_decay = 0.0005 Optimizer groups: 95 .bias, 95 conv.weight, 98 other train: Scanning 'C:\Users\mdari\YOLOv7_Custom\yolov7-custom\data\train\labels.cache' images and labels... 60 found, 0 m Traceback (most recent call last): File "C:\Users\mdari\YOLOv7_Custom\yolov7-custom\train.py", line 616, in train(hyp, opt, device, tb_writer) File "C:\Users\mdari\YOLOv7_Custom\yolov7-custom\train.py", line 245, in train dataloader, dataset = create_dataloader(train_path, imgsz, batch_size, gs, opt, File "C:\Users\mdari\YOLOv7_Custom\yolov7-custom\utils\datasets.py", line 69, in create_dataloader dataset = LoadImagesAndLabels(path, imgsz, batch_size, File "C:\Users\mdari\YOLOv7_Custom\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\mdari\miniconda3\envs\yolov7_custom\lib\site-packages\numpy__init.py", line 284, in getattr__ raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'int'

Common solutions online says to find any files named 'numpy.py', I checked and I don't have it. I've also uninstalled and reinstalled numpy through pip.

croust commented 1 year ago

Fixed by https://github.com/WongKinYiu/yolov7/issues/1280

SkalskiP commented 1 year ago

@croust it is not fixed. No PR have been merged. https://github.com/WongKinYiu/yolov7/pull/1272 is till open.

suriyahgit commented 1 year ago

It can be solved if the numpy version numpy==1.23.5 used instead of numpy==1.24.0. I have tried it and the issue is resolved. 'pip install --upgrade numpy==1.23.5' in the project environement for pip

SkalskiP commented 1 year ago

@suriyahgit that’s not a solution. If you do it this way, you’ll always be bound to this numpy version. We shouldn’t restrict numpy version but solve the actual problem in the code.

Nyove commented 1 year ago

@suriyahgit Thanks, I have solved the issue.