Skip to content
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

RuntimeError: non-positive stride is not supported #5535

Closed
1 of 2 tasks
sudheer-palaparambil opened this issue Nov 6, 2021 · 4 comments
Closed
1 of 2 tasks

RuntimeError: non-positive stride is not supported #5535

sudheer-palaparambil opened this issue Nov 6, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@sudheer-palaparambil
Copy link

Search before asking

  • I have searched the YOLOv5 issues and found no similar bug report.

YOLOv5 Component

Training

Bug

Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf...
train: weights=, cfg=./models/custom_yolov5s.yaml, data=../data.yaml, hyp=data/hyps/hyp.scratch.yaml, epochs=300, batch_size=32, imgsz=416, rect=False, resume=False, nosave=True, noval=False, noautoanchor=False, evolve=None, bucket=, cache=ram, image_weights=False, device=, multi_scale=False, single_cls=False, adam=False, sync_bn=False, workers=8, project=runs/train, name=yolov5s_results, exist_ok=False, quad=False, linear_lr=False, label_smoothing=0.0, patience=100, freeze=0, save_period=-1, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest
github: up to date with https://github.com/ultralytics/yolov5
YOLOv5 🚀 v6.0-66-g3364379 torch 1.9.0+cu111 CUDA:0 (Tesla P100-PCIE-16GB, 16281MiB)

hyperparameters: lr0=0.01, lrf=0.1, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0
Weights & Biases: run 'pip install wandb' to automatically track and visualize YOLOv5 🚀 runs (RECOMMENDED)
TensorBoard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/

             from  n    params  module                                  arguments                     

0 -1 1 3520 models.common.Focus [3, 32, 3]
1 -1 1 18560 models.common.Conv [32, 64, 3, 2]
2 -1 1 20672 models.common.Bottleneck [64, 64]
3 -1 1 73984 models.common.Conv [64, 128, 3, 2]
4 -1 3 161152 models.common.BottleneckCSP [128, 128, 3]
5 -1 1 295424 models.common.Conv [128, 256, 3, 2]
6 -1 3 641792 models.common.BottleneckCSP [256, 256, 3]
7 -1 1 1180672 models.common.Conv [256, 512, 3, 2]
8 -1 1 656896 models.common.SPP [512, 512, [5, 9, 13]]
9 -1 2 1905152 models.common.BottleneckCSP [512, 512, 2]
10 -1 1 1248768 models.common.BottleneckCSP [512, 512, 1, False]
11 -1 1 19 torch.nn.modules.conv.Conv2d [18, 1, 1, 0]
12 -2 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
13 [-1, 6] 1 0 models.common.Concat [1]
14 -1 1 197120 models.common.Conv [768, 256, 1, 1]
15 -1 1 313088 models.common.BottleneckCSP [256, 256, 1, False]
16 -1 1 19 torch.nn.modules.conv.Conv2d [18, 1, 1, 0]
17 -2 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest']
18 [-1, 4] 1 0 models.common.Concat [1]
19 -1 1 49408 models.common.Conv [384, 128, 1, 1]
20 -1 1 78720 models.common.BottleneckCSP [128, 128, 1, False]
21 -1 1 19 torch.nn.modules.conv.Conv2d [18, 1, 1, 0]
22 [] 1 0 models.yolo.Detect [1, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], []]
Traceback (most recent call last):
File "train.py", line 628, in
main(opt)
File "train.py", line 525, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 126, in train
model = Model(cfg, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device) # create
File "/content/yolov5/models/yolo.py", line 113, in init
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
File "/content/yolov5/models/yolo.py", line 127, in forward
return self._forward_once(x, profile, visualize) # single-scale inference, train
File "/content/yolov5/models/yolo.py", line 150, in _forward_once
x = m(x) # run
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/conv.py", line 443, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/conv.py", line 440, in _conv_forward
self.padding, self.dilation, self.groups)
RuntimeError: non-positive stride is not supported

Environment

I am new to machine learning. I am trying to run this example @ https://blog.roboflow.com/retail-store-item-detection-using-yolov5/

Google Colab Pro with Python 3.7.12
YOLOv5 🚀 v6.0-66-g3364379 torch 1.9.0+cu111 CUDA:0 (Tesla P100-PCIE-16GB, 16281MiB)
Using torch 1.9.0+cu111 _CudaDeviceProperties(name='Tesla P100-PCIE-16GB', major=6, minor=0, total_memory=16280MB, multi_processor_count=56)

The train command gives the following error.
RuntimeError: non-positive stride is not supported

!python train.py --img 416 --batch 32 --epochs 300 --data '../data.yaml' --cfg ./models/custom_yolov5s.yaml --weights '' --name yolov5s_results --nosave --cache

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@sudheer-palaparambil sudheer-palaparambil added the bug Something isn't working label Nov 6, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2021

👋 Hello @sudheer-palaparambil, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution.

If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available.

For business inquiries or professional support requests please visit https://ultralytics.com or email Glenn Jocher at glenn.jocher@ultralytics.com.

Requirements

Python>=3.6.0 with all requirements.txt installed including PyTorch>=1.7. To get started:

$ git clone https://github.com/ultralytics/yolov5
$ cd yolov5
$ pip install -r requirements.txt

Environments

YOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

CI CPU testing

If this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on MacOS, Windows, and Ubuntu every 24 hours and on every commit.

@Zengyf-CVer
Copy link
Contributor

@sudheer-palaparambil
You are using the pre-training weights of v6.0, and the structure is customized, but you use the structure in v5.0, such as Focus, etc., which causes the model to not match.

@glenn-jocher
Copy link
Member

@sudheer-palaparambil yes, your source seems a bit outdated. You can get started training a supermarket dataset with YOLOv5 easily like this. The SKU-110K dataset will autodownload to your machine on first use:

git clone https://github.com/ultralytics/yolov5
cd yolov5
pip install -r requirements.txt

python train.py --data SKU-110K.yaml

@sudheer-palaparambil
Copy link
Author

Many thanks @Zengyf-CVer and @glenn-jocher. I am going to try it with YOLOv5 and SKU-110K dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants