PaddleX icon indicating copy to clipboard operation
PaddleX copied to clipboard

FasterRCNN加载模型之后预测图像报错

Open libingbingdev opened this issue 4 years ago • 2 comments

问题类型:模型部署 问题描述
运行环境: Windows7,64位操作系统; paddlepaddle-gpu == 2.1.2.post110; paddlex == 2.0.0rc4; NVIDIA-SMI:451.8; Driver Version:451.8; CUDA Version:11.0; CUDNN Version:11.0;

使用FasterRCNN作为Baseline,(backbone为ResNet50_vd_ssld)训练完目标检测模型之后,进行图像预测,模型配置文件如下: Model: FasterRCNN Transforms:

  • ResizeByShort: interp: LINEAR max_size: 2048 short_size: 1024
  • Normalize: is_scale: true max_val:
    • 255.0
    • 255.0
    • 255.0 mean:
    • 0.485
    • 0.456
    • 0.406 min_val:
    • 0
    • 0
    • 0 std:
    • 0.229
    • 0.224
    • 0.225
  • Padding: im_padding_value:
    • 0.0
    • 0.0
    • 0.0 label_padding_value: 255 offsets: null pad_mode: 0 size_divisor: 32 target_size: null _Attributes: eval_metrics: bbox_map: 61.77607962049713 fixed_input_shape:
    • -1
    • 3
    • -1
    • -1 labels:
    • diandu
    • guahua
    • liehen
    • posun
    • queliao
    • waixie
    • zangwu model_type: detector num_classes: 8 _init_params: anchor_sizes:
      • 32
      • 64
      • 128
      • 256
      • 512 aspect_ratios:
    • 0.5
    • 1.0
    • 2.0 backbone: ResNet50_vd_ssld fpn_num_channels: 64 keep_top_k: 100 nms_threshold: 0.5 num_classes: 8 rpn_batch_size_per_im: 256 rpn_fg_fraction: 0.5 score_threshold: 0.05 test_post_nms_top_n: 300 test_pre_nms_top_n: 500 with_dcn: true with_fpn: true completed_epochs: 0 status: Infer version: 2.0.0rc4

预测代码如下: model = load_model(path_to_model) image = cv2.imread(path_to_image) result = model.predict(image) pdx.det.visualize(image, result, threshold=0.5, save_dir='./base') 出现**“Python已停止运行”**,系统异常退出: 报错信息如下: C:\anaconda\workspace\lib\site-packages\win32\lib\pywintypes.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentati on for alternative uses import imp, sys, os C:\anaconda\workspace\lib\site-packages\paddle\distributed\parallel.py:120: UserWarning: Currently not a parallel execution environment, paddle.distributed.init_parall el_env will not do anything. "Currently not a parallel execution environment, paddle.distributed.init_parallel_env will not do anything." 2.0.0rc4 [2021-09-01 11:22:25,543] predict.py->load_model line:28 [INFO]Loading model... W0901 11:22:25.553900 6864 device_context.cc:404] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 11.0, Runtime API Version: 11.0 W0901 11:22:25.560899 6864 device_context.cc:422] device: 0, cuDNN Version: 8.0. 2021-09-01 11:22:28 [INFO] Model[FasterRCNN] loaded. [2021-09-01 11:22:28,673] predict.py->load_model line:31 [INFO]Model loaded.

Process finished with exit code 255

但在同一环境下,采用MobileNetV3_large_ssld作为baseline训练完图像分类检测模型后,进行图像预测,预测正常。 预测代码如下: model = load_model(config.path_to_model) image = cv2.imread(path_to_image) result = model.predict(image) print('result = {}'.format(result)) 打印信息如下: ...... [2021-09-01 13:57:22,144] predict.py->load_model line:29 [INFO]Loading model... W0901 13:57:22.150899 6552 device_context.cc:404] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 11.0, Runtime API Version: 11.0 W0901 13:57:22.175899 6552 device_context.cc:422] device: 0, cuDNN Version: 8.0. C:\anaconda\workspace\lib\site-packages\paddle\fluid\backward.py:1666: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.a bc' is deprecated since Python 3.3,and in 3.9 it will stop working return list(x) if isinstance(x, collections.Sequence) else [x] 2021-09-01 13:57:23 [INFO] Model[MobileNetV3_large_ssld] loaded. [2021-09-01 13:57:23,835] predict.py->load_model line:32 [INFO]Model loaded. [2021-09-01 13:57:25,702] predict.py->predict_img line:39 [INFO][{'category_id': 2, 'category': 'miss', 'score': 0.93039525}] result_clip = [{'category_id': 2, 'category': 'miss', 'score': 0.93039525}]

Process finished with exit code 0

========================

请在这里描述您在使用过程中的问题,说明您的部署环境,部署需求,模型类型和应用场景等,便于开发人员快速响应。

libingbingdev avatar Sep 01 '21 06:09 libingbingdev

更新下paddlex试试:

pip  install paddlex==2.0.0 -U

FlyingQianMM avatar Sep 02 '21 02:09 FlyingQianMM

更新下paddlex试试:

pip  install paddlex==2.0.0 -U

感谢,更新了paddlex之后问题解决了。请问是什么原因呢?

libingbingdev avatar Sep 06 '21 08:09 libingbingdev