PaddlePaddle / PaddleSeg

Easy-to-use image segmentation library with awesome pre-trained model zoo, supporting wide-range of practical tasks in Semantic Segmentation, Interactive Segmentation, Panoptic Segmentation, Image Matting, 3D Segmentation, etc.
https://arxiv.org/abs/2101.06175
Apache License 2.0
8.69k stars 1.68k forks source link

[General Issue]deploy/python/infer.py \transforms.py", line 63, in __call__ cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'cvtColor' #2365

Closed monkeycc closed 1 year ago

monkeycc commented 2 years ago

欢迎您反馈PaddleSeg使用问题,辛苦您提供以下信息,方便我们快速定位和解决问题:

  1. PaddleSeg版本:(paddleseg 2.5.0)
  2. PaddlePaddle版本:(paddlepaddle-gpu 2.3.0.post112)
  3. 操作系统信息:(Windows)
  4. Python版本号:(Python3.7)
  5. CUDA/cuDNN版本:(cuda11.2 cudnn8.2)
  6. 其他内容: (增加其他与问题相关的内容)

 python deploy/python/infer.py 
--config 0Pdparams/aaa/deploy.yaml     
--image_path  F:/aaa
--save_dir output/result_infer

D:\anaconda3\envs\PaddleSeg\lib\site-packages\paddleseg-2.5.0-py3.7.egg\paddleseg\models\losses\rmi_loss.py:78: DeprecationWarning: invalid escape sequence \i
D:\anaconda3\envs\PaddleSeg\lib\site-packages\paddleseg-2.5.0-py3.7.egg\paddleseg\models\losses\rmi_loss.py:78: DeprecationWarning: invalid escape sequence \i
2022-07-23 14:56:00 [INFO]      Use GPU
W0723 14:56:01.244861 18732 analysis_predictor.cc:1086] The one-time configuration of analysis predictor failed, which may be due to native predictor called first and its configurations taken effect.
e[1me[35m--- Running analysis [ir_graph_build_pass]e[0m
e[1me[35m--- Running analysis [ir_graph_clean_pass]e[0m
e[1me[35m--- Running analysis [ir_analysis_pass]e[0m
e[32m--- Running IR pass [is_test_pass]e[0m
e[32m--- Running IR pass [simplify_with_basic_ops_pass]e[0m
e[32m--- Running IR pass [conv_bn_fuse_pass]e[0m
I0723 14:56:01.345599 18732 fuse_pass_base.cc:57] ---  detected 39 subgraphs
e[32m--- Running IR pass [conv_eltwiseadd_bn_fuse_pass]e[0m
I0723 14:56:01.351449 18732 fuse_pass_base.cc:57] ---  detected 4 subgraphs
e[32m--- Running IR pass [embedding_eltwise_layernorm_fuse_pass]e[0m
e[32m--- Running IR pass [multihead_matmul_fuse_pass_v2]e[0m
e[32m--- Running IR pass [gpu_cpu_squeeze2_matmul_fuse_pass]e[0m
e[32m--- Running IR pass [gpu_cpu_reshape2_matmul_fuse_pass]e[0m
e[32m--- Running IR pass [gpu_cpu_flatten2_matmul_fuse_pass]e[0m
e[32m--- Running IR pass [gpu_cpu_map_matmul_v2_to_mul_pass]e[0m
e[32m--- Running IR pass [gpu_cpu_map_matmul_v2_to_matmul_pass]e[0m
e[32m--- Running IR pass [gpu_cpu_map_matmul_to_mul_pass]e[0m
e[32m--- Running IR pass [fc_fuse_pass]e[0m
e[32m--- Running IR pass [fc_elementwise_layernorm_fuse_pass]e[0m
e[32m--- Running IR pass [conv_elementwise_add_act_fuse_pass]e[0m
e[32m--- Running IR pass [conv_elementwise_add2_act_fuse_pass]e[0m
e[32m--- Running IR pass [conv_elementwise_add_fuse_pass]e[0m
I0723 14:56:01.373414 18732 fuse_pass_base.cc:57] ---  detected 3 subgraphs
e[32m--- Running IR pass [transpose_flatten_concat_fuse_pass]e[0m
e[32m--- Running IR pass [runtime_context_cache_pass]e[0m
e[1me[35m--- Running analysis [ir_params_sync_among_devices_pass]e[0m
I0723 14:56:01.377400 18732 ir_params_sync_among_devices_pass.cc:100] Sync params from CPU to GPU
e[1me[35m--- Running analysis [adjust_cudnn_workspace_size_pass]e[0m
e[1me[35m--- Running analysis [inference_op_replace_pass]e[0m
e[1me[35m--- Running analysis [memory_optimize_pass]e[0m
I0723 14:56:01.401321 18732 memory_optimize_pass.cc:216] Cluster name : relu_0.tmp_0  size: 16777216
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : relu_9.tmp_0  size: 1048576
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : relu_12.tmp_0  size: 524288
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : x  size: 6291456
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : relu_1.tmp_0  size: 8388608
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : batch_norm_3.tmp_2  size: 4194304
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : relu_25.tmp_0  size: 262144
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : pool2d_1.tmp_0  size: 2097152
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : shape_1.tmp_0_slice_0  size: 8
I0723 14:56:01.402319 18732 memory_optimize_pass.cc:216] Cluster name : shape_0.tmp_0_slice_0  size: 8
I0723 14:56:01.403306 18732 memory_optimize_pass.cc:216] Cluster name : mean_1.tmp_0  size: 4
e[1me[35m--- Running analysis [ir_graph_to_program_pass]e[0m
I0723 14:56:01.443854 18732 analysis_predictor.cc:1007] ======= optimize end =======
I0723 14:56:01.444854 18732 naive_executor.cc:102] ---  skip [feed], feed -> x
I0723 14:56:01.446844 18732 naive_executor.cc:102] ---  skip [argmax_0.tmp_0], fetch -> fetch
Traceback (most recent call last):
  File "deploy/python/infer.py", line 430, in <module>
    main(args)
  File "deploy/python/infer.py", line 418, in main
    predictor.run(imgs_list)
  File "deploy/python/infer.py", line 367, in run
    self._preprocess(p) for p in imgs_path[i:i + args.batch_size]
  File "deploy/python/infer.py", line 367, in <listcomp>
    self._preprocess(p) for p in imgs_path[i:i + args.batch_size]
  File "deploy/python/infer.py", line 392, in _preprocess
    return self.cfg.transforms(data)['img']
  File "D:\anaconda3\envs\PaddleSeg\lib\site-packages\paddleseg-2.5.0-py3.7.egg\paddleseg\transforms\transforms.py", line 63, in __call__
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'cvtColor'
> Overload resolution failed:
>  - src is not a numpy array, neither a scalar
>  - Expected Ptr<cv::UMat> for argument 'src'
haoyuying commented 2 years ago

请检查输入图片的是否正确输入,图片路径等是否错误或者有非法图片等,报错信息为没有读到合法的数据,图片没有传入。

gg22mm commented 2 years ago

请检查输入图片的是否正确输入,图片路径等是否错误或者有非法图片等,报错信息为没有读到合法的数据,图片没有传入。

我也遇到同样的问题了,不知道怎么回事? 图片肯定是存在的,路径也没问题,很奇怪: 只有是deploy 才有这个问题 如: predict.py 成功 python predict.py --config configs/quick_start/pp_liteseg_optic_disc_512x512_1k_st.yml --model_path ./weigth/model.pdparams --image_path data/tongue/JPEGImages/1json.png --save_dir output #这个是成功的

deploy:失败 python deploy/python/infer.py --config ./inference_model/deploy.yaml --image_path data/tongue/JPEGImages/1json.png #这个是失败的

qmzpg commented 2 years ago

I get the same problem. It seems a bug in paddleseg

xiayuan commented 2 years ago

It is actually a bug, I fixed it, in infer.py line 393: "return self.cfg.transformers(data)['img']" should be "return self.cfg.transformers(data['img'])[0]" change the code, then problem could be solved.

juncaipeng commented 2 years ago

请检查输入图片的是否正确输入,图片路径等是否错误或者有非法图片等,报错信息为没有读到合法的数据,图片没有传入。

我也遇到同样的问题了,不知道怎么回事? 图片肯定是存在的,路径也没问题,很奇怪: 只有是deploy 才有这个问题 如: predict.py 成功 python predict.py --config configs/quick_start/pp_liteseg_optic_disc_512x512_1k_st.yml --model_path ./weigth/model.pdparams --image_path data/tongue/JPEGImages/1json.png --save_dir output #这个是成功的

deploy:失败 python deploy/python/infer.py --config ./inference_model/deploy.yaml --image_path data/tongue/JPEGImages/1json.png #这个是失败的

都是window系统上的错误吗?

juncaipeng commented 1 year ago

It is not a bug. Please remove old paddleseg by pip uninstall paddleseg, and then use PaddleSeg 2.7 to run deploy/python/infer.py

lixiaochen123 commented 1 year ago

我也遇到了同样的问题,已经解决。原因是我用pip install 装了Paddleseg 2.5.0, 又从github上装了2.7.0.所以解决方法是:pip uninstall paddleseg 卸载掉2.5.0版本的,就可以了。