PaddleDetection的初步认知(一)

2021SC@SDUSC 

一周以来,我通过在网上查阅很多的资料,阅读源码,对PaddleDetection的相关知识有了初步的认知。

1.模型训练/评估/预测

infer.py —— 模型预测

# 预测
python tools/infer.py -c configs/faster_rcnn_r50_1x.yml --infer_img=demo/000000570688.jpg

2.模型配置文件说明——model.yml

在PaddleDetection使用model.yml来配置模型的结构;
模型参数:

  • PostProcess:后处理操作,(仅用于“CornerNet”模型)

3.运行分析 

  3.1 图像预测 

我们可以使用如下的命令来预测图像中的物体目标

# 用PP-YOLO算法在COCO数据集上预训练模型预测一张图片
python tools/infer.py -c configs/ppyolo/ppyolo.yml -o use_gpu=true weights=https://paddlemodels.bj.bcebos.com/object_detection/ppyolo.pdparams --infer_img=demo/000000014439.jpg

(demo/000000014439.jpg已经内置在PaddleDetection的repo文件夹中) 

4.代码说明 

  4.1 tools/infer.py

   用于进行图像的预测

  4.1.1 路径预设代码 

import os, sys
# add python path of PadleDetection to sys.path
parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if parent_path not in sys.path:
    sys.path.append(parent_path)
    # 使用sys.path.append添加环境变量,在脚本执行完成之后则会失效

  4.2 utils/post_process.py 

  用于目标检测的后处理;

    4.2.1 corner_post_process()

    用于CornerNet的后处理函数;
    参数: 

  • results:
    dict{‘bbox’, ‘im_id’},检测结果;其中字典中的属性含义如下:
    • bbox: 检测框信息,包含类别和坐标信息
    • im_id: 图像id

    代码说明: 

def corner_post_process(results, config, num_classes):
    detections = results['bbox'][0]
    keep_inds = (detections[:, 1] > -1)
    detections = detections[keep_inds]
    labels = detections[:, 0]
    scores = detections[:, 1]
    boxes = detections[:, 2:6]
    cls_boxes = get_nms_result(
        boxes, scores, config, num_classes, background_label=-1, labels=labels)
    results.update({'bbox': (cls_boxes, [[len(cls_boxes)]])})

5.模型介绍

CBResNet200-vd-FPN-Nonlocal——“PaddleDetection的最强模型”
 此模型是PaddleDetection中目前在COCO数据集上的最强模型,mAP=53.3

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值