WongKinYiu / yolor

implementation of paper - You Only Learn One Representation: Unified Network for Multiple Tasks (https://arxiv.org/abs/2105.04206)
GNU General Public License v3.0
1.98k stars 524 forks source link

augmentstion while inference is not working #133

Open AndreiErofeev opened 2 years ago

AndreiErofeev commented 2 years ago

When I'm running inference with the following command: python detect.py --source ../input/ --cfg cfg/yolor_p6.cfg --weights runs/train/yolor_multy6/weights/best.pt --img-size 640 --device 3 --augment --names data/deers.names

and getting the error:

File "/home/yolor/detect.py", line 186, in detect() File "/home/yolor/detect.py", line 85, in detect pred = model(img, augment=opt.augment)[0] File "/home/miniconda3/envs/rn/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, *kwargs) File "/home/yolor/models/models.py", line 553, in forward y.append(self.forward_once(xi)[0]) File "/home/yolor/models/models.py", line 594, in forward_once x = module(x, out) # WeightedFeatureFusion(), FeatureConcat() File "/home/miniconda3/envs/rn/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(input, **kwargs) File "/home/yolor/utils/layers.py", line 69, in forward return torch.cat([outputs[i] for i in self.layers], 1) if self.multiple else outputs[self.layers[0]] RuntimeError: Sizes of tensors must match except in dimension 3. Got 18 and 17 (The offending index is 0)

WongKinYiu commented 2 years ago

it due to --img-size 640 with --augment will generate the image with size not be 64x as input. you could add check size of s in https://github.com/WongKinYiu/yolor/blob/main/models/models.py#L544 to solve the problem.