文档
注册

MMDetection

功能简介

MMDetection是一个基于PyTorch的开源对象检测工具箱,提供了已公开发表的多种流行的检测组件,通过这些组件的组合可以迅速搭建出各种检测框架。更多说明可前往官方文档

安装方法

当前昇腾适配的版本要求MMDetection版本为2.26.0及以上.

  1. 请参考MMCV完成MMCV的安装。
  2. 安装MMDetection。
    • 将MMDetection用作依赖或第三方软件包,请使用pip安装:
      pip install mmdet
    • 若用户想直接开发和运行MMDetection,请从源码安装:
      git clone https://github.com/open-mmlab/mmdetection.git
      cd mmdetection
      pip install -v -e .
      # "-v" means verbose, or more output
      # "-e" means installing a project in editable mode,
      # thus any local modifications made to the code will take effect without reinstallation.

使用方法

为了验证是否正确安装了MMDetection和所需的环境,我们可以运行以下示例的Python代码来初始化检测器并推理一个演示图像。

  1. 下载config和checkpoint文件。
    mim download mmdet --config yolov3_mobilenetv2_320_300e_coco --dest .

    下载需要几秒或更长时间,具体取决于你的网络环境。下载完成后,你可以在当前文件夹中找到yolov3_mobilenetv2_320_300e_coco.py和yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth两个文件。

  2. 验证推理demo。
    用户请先点击链接获取用于demo的jpg图像文件,并上传至自己的运行目录下demo文件夹。
    • 若用户将MMDetection用作依赖或第三方软件包,使用pip安装的MMDetection,请新建脚本并写入以下代码运行:
      from mmdet.apis import init_detector, inference_detector
      config_file = 'yolov3_mobilenetv2_320_300e_coco.py'
      checkpoint_file = 'yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth'
      model = init_detector(config_file, checkpoint_file, device='npu:0')  
      model_result = inference_detector(model, 'demo/demo.jpg')
      print(model_result)

      可以看到打印出来的数组列表,指示检测到的标注框,如下图所示。

    • 若用户是从源安装MMDetection,运行以下命令:
      python demo/image_demo.py demo/demo.jpg yolov3_mobilenetv2_320_300e_coco.py yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth --device npu --out-file result.jpg

      当前文件夹内会生成一个新图像结果.jpg文件,图中会出现标注框框在汽车、长凳等物体上。

支持模型

适配昇腾的MMDetection支持模型列表如下。更多模型验证结果和说明可点击链接前往。

表1 适配昇腾的MMDetection支持模型列表

模型

是否支持

ssd300

ssd512

ssdlite-mbv2

retinanet-r18

retinanet-r50

yolov3-608

yolox-s

centernet-r18

fcos-r50

solov2-r50

搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词