YOLOX icon indicating copy to clipboard operation
YOLOX copied to clipboard

IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

Open ericwang1126 opened this issue 2 years ago • 4 comments

I Follow the Github step to inference picture and I didn't modify the code. When I type 'python tools/demo.py image -f exps/default/yolox_s.py -c preModels/yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result --device gpu' in terminal The log shows below: Traceback (most recent call last): File "tools/demo.py", line 320, in main(exp, args) File "tools/demo.py", line 269, in main logger.info("Model Summary: {}".format(get_model_info(model, exp.test_size))) File "/home/u1764740/train/YOLOX/yolox/utils/model_utils.py", line 26, in get_model_info flops, params = profile(deepcopy(model), inputs=(img,), verbose=False) File "/home/u1764740/.local/lib/python3.8/site-packages/thop/profile.py", line 211, in profile model(*inputs) File "/home/u1764740/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/u1764740/train/YOLOX/yolox/models/yolox.py", line 30, in forward fpn_outs = self.backbone(x) File "/home/u1764740/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/home/u1764740/train/YOLOX/yolox/models/yolo_pafpn.py", line 99, in forward f_out0 = torch.cat([f_out0, x1], 1) # 512->1024/16 IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)

Finally I run the code on my another PC, it can work.

ericwang1126 avatar Mar 09 '22 15:03 ericwang1126

Could you plz provide more environment info like your torch version, git commit hash and so on? Are you training COCO dataset?

FateScript avatar Mar 10 '22 03:03 FateScript

My conda environment shows below: pytorch 1.10.2 py3.8_cuda10.2_cudnn7.6.5_0 pytorch python 3.8.5 torchvision 0.11.3 py38_cu102 pytorch NO, I only used pretrain weight (yolox-m.pth) to inference my video.

My commit step shows below: git clone https://github.com/Megvii-BaseDetection/YOLOX.git

cd YOLOX

conda create -n torchYolo python=3.8.5

conda activate torchYolo

pip3 install -U pip && pip3 install -r requirements.txt

python3 setup.py develop

pip3 install cython

pip install pycocotools

python tools/demo.py image -n yolox-s -c preModels/yolox_s.pth --path assets/dog.jpg --conf 0.25 --nms 0.45 --tsize 640 --save_result

ericwang1126 avatar Mar 10 '22 04:03 ericwang1126

您的问题解决了吗 我今天也遇到同样的问题

tyj1225 avatar Jun 01 '22 13:06 tyj1225

我後來有解決,不過有點忘了,我當時好像是重新安裝thop

up198 avatar Jun 04 '22 02:06 up198