1、目标检测
图像分类:分类、概率
目标检测:给出位置、分类、概率
数据标注:坐上坐标,右下坐标 矩形框 (x1,y1,x2,y2,class)
目标检测常用数据集:PASCAL VOC、MS COCO(30W+图片,80个分类)
![计算机视觉:目标检测、人脸识别-BtoAI 计算机视觉:目标检测、人脸识别-BtoAI](https://btoai.com/wp-content/uploads/2023/05/64088a9ebc4d53f293e9c5ef44e0816d.png)
目标检测的操作:
- IoU 表示两个矩形的重叠程度
- NMS 去掉多个重复的预测框,设置一个IoU阈值,然后对分数进行排序,计算IoU选一个最好的
评价指标:
![计算机视觉:目标检测、人脸识别-BtoAI 计算机视觉:目标检测、人脸识别-BtoAI](https://btoai.com/wp-content/uploads/2023/05/ab49701132eb9cf6200885019796431e.png)
2、检测方法
![计算机视觉:目标检测、人脸识别-BtoAI 计算机视觉:目标检测、人脸识别-BtoAI](https://btoai.com/wp-content/uploads/2023/05/6a83239aec118c8222ee72f9f29ecb73.png)
二阶段目标检测—Faster RCNN,速度慢
一阶段目标检测—YOLO V8,快
目标检测新范式—DETR,训练时间长
3、实战
![计算机视觉:目标检测、人脸识别-BtoAI 计算机视觉:目标检测、人脸识别-BtoAI](https://btoai.com/wp-content/uploads/2023/05/563ddfab14475e629aed24f150f00047.png)
![计算机视觉:目标检测、人脸识别-BtoAI 计算机视觉:目标检测、人脸识别-BtoAI](https://btoai.com/wp-content/uploads/2023/05/e5cd28019937d614a9065d9a31ca4fca.png)
# 模型推理
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、人脸检测
![计算机视觉:目标检测、人脸识别-BtoAI 计算机视觉:目标检测、人脸识别-BtoAI](https://btoai.com/wp-content/uploads/2023/05/304b0302c59a237092ebfb53be599849.png)
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