[Bug]: cv2.error: OpenCV(4.9.0) 👎 error: (-5:Bad argument) in function 'rectangle' #138
Open
3 tasks done
Labels
bug
Something isn't working
Before Reporting
I have pulled the latest code of main branch to run again and the bug still existed. 我已经拉取了主分支上最新的代码,重新运行之后,问题仍不能解决。
I have read the README carefully and no error occured during the installation process. (Otherwise, we recommand that you can ask a question using the Question template) 我已经仔细阅读了README上的操作指引,并且在安装过程中没有错误发生。(否则,我们建议您使用Question模板向我们进行提问)
Search before reporting
OS
Windows
Device
Nvidia 4070Ti
CUDA version
11.8
TensorRT version
8.6.1.6
Python version
3.8
PyTorch version
2.2.2
torchvision version
0.17.2
Describe the bug
运行推理时,在damo/utils/visualize.py中报错,显示numpy数组是只读的不允许操作。
`
File "E:\proj\DAMO-YOLO\damo\utils\visualize.py", line 30, in vis
cv2.rectangle(img, (x0, y0), (x1, y1), color, 2)
│ │ │ │ │ │ │ └ [0, 113, 188]
│ │ │ │ │ │ └ 261
│ │ │ │ │ └ 322
│ │ │ │ └ 229
│ │ │ └ 309
│ │ └ array([[[255, 255, 255],
│ │ [255, 255, 255],
│ │ [255, 255, 255],
│ │ ...,
│ │ [255, 255, 255],
│ │ [255...
│ └
└ <module 'cv2' from 'C:\Users\chonpsk\.conda\envs\DAMO-YOLO\lib\site-packages\cv2\init.py'>
cv2.error: OpenCV(4.9.0) 👎 error: (-5:Bad argument) in function 'rectangle'
To Reproduce
python demo.py image -f ./configs/damoyolo_tinynasL20_T.py --engine workdirs/damoyolo_tinynasL20_T/epoch_300_ckpt.pth --conf 0.1 --inf
er_size 640 640 --device cuda --path datasets/Custom_coco/images/val/66_crop_0.jpg
Hyper-parameters/Configs
使用默认超参数
Logs
2024-04-11 10:13:31.168 | ERROR | main::356 - An error has been caught in function '', process 'MainProcess' (980), thread 'MainThread' (23684):
Traceback (most recent call last):
File "demo.py", line 321, in main
vis_res = infer_engine.visualize(origin_img, bboxes, scores, cls_inds, conf=args.conf, save_name=os.path.basename(args.path), save_result=args.save_result)
│ │ │ │ │ │ │ │ │ │ │ │ │ │ └ True
│ │ │ │ │ │ │ │ │ │ │ │ │ └ Namespace(camid=0, conf=0.6, confi
g_file='./configs/damoyolo_tinynasL20_T.py', device='cuda', end2end=False, engine='workdirs...
│ │ │ │ │ │ │ │ │ │ │ │ └ 'datasets/Custom_coco/images/val/66_crop_0.jpg'
│ │ │ │ │ │ │ │ │ │ │ └ Namespace(camid=0, conf=0.6, config_file='./configs/damoyo
lo_tinynasL20_T.py', device='cuda', end2end=False, engine='workdirs...
│ │ │ │ │ │ │ │ │ │ └ <function basename at 0x000001C95AD39EE0>
│ │ │ │ │ │ │ │ │ └ <module 'ntpath' from 'C:\Users\chonpsk\.conda\envs\DAMO-YOLO\lib
\ntpath.py'>
│ │ │ │ │ │ │ │ └ <module 'os' from 'C:\Users\chonpsk\.conda\envs\DAMO-YOLO\lib\os.py'
d2end=False, engine='workdirs...
│ │ │ │ │ └ tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
│ │ │ │ │ 0., 0., 0., 0...
│ │ │ │ └ tensor([0.6785, 0.6641, 0.6581, 0.6514, 0.6470, 0.6399, 0.5757, 0.5683, 0.5609,
│ │ │ │ 0.5585, 0.5564, 0.5532, 0.5524, 0.521...
│ │ │ └ tensor([[309.0302, 229.5414, 322.8981, 261.2090],
│ │ │ [267.1926, 28.5143, 280.6399, 46.0551],
│ │ │ [307.3100, 135.57...
│ │ └ array([[[255, 255, 255],
│ │ [255, 255, 255],
│ │ [255, 255, 255],
│ │ ...,
│ │ [255, 255, 255],
│ │ [255...
│ └ <function Infer.visualize at 0x000001C91010F700>
└ <main.Infer object at 0x000001C95AE46550>
File "demo.py", line 249, in visualize
vis_img = vis(image, bboxes, scores, cls_inds, conf, self.class_names)
│ │ │ │ │ │ │ └ ['qx']
│ │ │ │ │ │ └ <main.Infer object at 0x000001C95AE46550>
│ │ │ │ │ └ 0.6
│ │ │ │ └ tensor([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
│ │ │ │ 0., 0., 0., 0...
│ │ │ └ tensor([0.6785, 0.6641, 0.6581, 0.6514, 0.6470, 0.6399, 0.5757, 0.5683, 0.5609,
│ │ │ 0.5585, 0.5564, 0.5532, 0.5524, 0.521...
│ │ └ tensor([[309.0302, 229.5414, 322.8981, 261.2090],
│ │ [267.1926, 28.5143, 280.6399, 46.0551],
│ │ [307.3100, 135.57...
│ └ array([[[255, 255, 255],
│ [255, 255, 255],
│ [255, 255, 255],
│ ...,
│ [255, 255, 255],
│ [255...
└ <function vis at 0x000001C910064DC0>
File "E:\proj\DAMO-YOLO\damo\utils\visualize.py", line 30, in vis
cv2.rectangle(img, (x0, y0), (x1, y1), color, 2)
│ │ │ │ │ │ │ └ [0, 113, 188]
│ │ │ │ │ │ └ 261
│ │ │ │ │ └ 322
│ │ │ │ └ 229
│ │ │ └ 309
│ │ └ array([[[255, 255, 255],
│ │ [255, 255, 255],
│ │ [255, 255, 255],
│ │ ...,
│ │ [255, 255, 255],
│ │ [255...
│ └
└ <module 'cv2' from 'C:\Users\chonpsk\.conda\envs\DAMO-YOLO\lib\site-packages\cv2\init.py'>
cv2.error: OpenCV(4.9.0) 👎 error: (-5:Bad argument) in function 'rectangle'
Screenshots
No response
Additional
将 vis内对numpy数组拷贝后进行操作解决该问题:
`def vis(img, boxes, scores, cls_ids, conf=0.5, class_names=None):
The text was updated successfully, but these errors were encountered: