模型描述
这里我们提供基于业界领先的目标检测框架DAMO-YOLO训练的检测模型:DAMO-YOLO-S。DAMO-YOLO是一个面向工业落地的目标检测框架,兼顾模型速度与精度,其训练的模型效果超越了目前的一众YOLO系列方法,并且仍然保持极高的推理速度。DAMO-YOLO引入TinyNAS技术,使得用户可以根据硬件算力进行低成本的检测模型定制,提高硬件利用效率并且获得更高精度。另外,DAMO-YOLO还对检测模型中的neck、head结构设计,以及训练时的标签分配、数据增广等关键因素进行了优化,具体细节可以参考我们的开源代码和技术报告。DAMO-YOLO-S是DAMO-YOLO提供的一系列模型中,平衡了速度和精度的最优模型之一。
模型评测
Model | size | mAPval 0.5:0.95 |
Latency(ms) T4-TRT-FP16 |
FLOPs (G) |
Parameters(M) |
---|---|---|---|---|---|
YOLOX-S | 640 | 40.5 | 3.20 | 26.8 | 9.0 |
YOLOv5-S | 640 | 37.4 | 3.04 | 16.5 | 7.2 |
YOLOv6-S | 640 | 43.5 | 3.10 | 44.2 | 17.0 |
PP-YOLOE-S | 640 | 43.0 | 3.21 | 17.4 | 7.9 |
DAMO-YOLO-S | 640 | 46.8 | 3.83 | 37.8 | 16.3 |
- 表中汇报的mAP是COCO2017 val集上的结果。
- 表中汇报的latency不包括后处理(nms)时间,其测试条件为:T4 GPU,TensorRT=7.2.1.6, CUDA=10.2, CUDNN=8.0.0.1。
使用范围
本模型适用范围较广,能对图片中包含的大部分前景物体(COCO 80类)进行定位。
使用方法
在ModelScope框架上,提供输入图片,即可以通过简单的Pipeline调用使用当前模型。具体代码示例如下:
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
object_detect = pipeline(Tasks.image_object_detection,model='damo/cv_tinynas_object-detection_damoyolo')
img_path ='https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/image_detection.jpg'
result = object_detect(img_path)
模型finetune
DAMO-YOLO现已支持模型finetune,要使用modelscope进行finetune需要首先将您的自有数据的图片和标注准换成标准COCO格式,finetune的样例如下。
# 准备预训练模型
model_id = 'damo/cv_tinynas_object-detection_damoyolo'
cache_path = snapshot_download(model_id)
# 开始训练
kwargs = dict(
cfg_file=os.path.join(cache_path, 'configuration.json'),
gpu_ids=[
0,
],
batch_size=16,
max_epochs=3,
num_classes=1,
pretrain_model=os.path.join(cache_path,
'damoyolo_tinynasL25_S.pt'),
cache_path=cache_path,
train_image_dir='./data/test/images/image_detection/images',
val_image_dir='./data/test/images/image_detection/images',
train_ann=
'./data/test/images/image_detection/annotations/coco_sample.json',
val_ann=
'./data/test/images/image_detection/annotations/coco_sample.json')
trainer = build_trainer(
name=Trainers.tinynas_damoyolo, default_args=kwargs)
trainer.train()
模型可视化效果
引用
@article{damoyolo,
title={DAMO-YOLO: A Report on Real-Time Object Detection Design},
author={Xianzhe Xu, Yiqi Jiang, Weihua Chen, Yilun Huang, Yuan Zhang and Xiuyu Sun},
journal={arXiv preprint arXiv:2211.15444v2},
year={2022}
}
评论