1、目标检测
图像分类:分类、概率
目标检测:给出位置、分类、概率
数据标注:坐上坐标,右下坐标 矩形框 (x1,y1,x2,y2,class)
目标检测常用数据集:PASCAL VOC、MS COCO(30W+图片,80个分类)
目标检测的操作:
- IoU 表示两个矩形的重叠程度
- NMS 去掉多个重复的预测框,设置一个IoU阈值,然后对分数进行排序,计算IoU选一个最好的
评价指标:
2、检测方法
二阶段目标检测—Faster RCNN,速度慢
一阶段目标检测—YOLO V8,快
目标检测新范式—DETR,训练时间长
3、实战
# 模型推理
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys
realtime_detector = pipeline(Tasks.image_object_detection, model=os.path.join(work_dir,'output'))
result = realtime_detector('./p001.png')
# 打印结果
print(result)
模型:
https://www.modelscope.cn/models/damo/cv_cspnet_image-object-detection_yolox/summary
4、人脸检测
face_detection = pipeline(task=Tasks.face_detection, model='damo/cv_ddsar_face-detection_iclr23-damofd-2.5G')
# 支持 url image and abs dir image path
img_path = './p02.png'
result = face_detection(img_path)
# 提供可视化结果
from modelscope.utils.cv.image_utils import draw_face_detection_result
from modelscope.preprocessors.image import LoadImage
img = LoadImage.convert_to_ndarray(img_path)
cv2.imwrite('srcImg.jpg', img)
img_draw = draw_face_detection_result('srcImg.jpg', result)
import matplotlib.pyplot as plt
plt.imshow(img_draw)
模型:
https://www.modelscope.cn/models/damo/cv_ddsar_face-detection_iclr23-damofd-2.5G/summary