人工智能之基于阿里云进行人脸特征检测部署

发布于:2025-02-11 ⋅ 阅读:(93) ⋅ 点赞:(0)

人工智能之基于阿里云进行人脸特征检测部署

需求描述

  1. 基于阿里云搭建真人人脸68个关键点检测模型,模型名称:Damo_XR_Lab/cv_human_68-facial-landmark-detection
  2. 使用上述模型进行人脸关键点识别,模型地址

业务实现

阿里云配置

阿里云配置如下:
在这里插入图片描述

依赖工具安装

# 安装ModelScope, 建议git安装
git clone https://github.com/modelscope/modelscope.git
cd modelscope
pip install -e .

SDK模型下载

# SDK模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('Damo_XR_Lab/cv_human_68-facial-landmark-detection')

图片验证

import cv2
import copy
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

model_id = 'Damo_XR_Lab/cv_human_68-facial-landmark-detection'
estimator = pipeline(Tasks.facial_68ldk_detection, model=model_id)

Input_file = '/mnt/workspace/105910221.jpg'
cv_img = cv2.imread(Input_file)
cv_img = cv2.resize(cv_img, (256, 256))

results = estimator(input=cv_img)
landmarks = results['landmarks']

image_draw = copy.copy(cv_img)
for num in range(landmarks.shape[0]):
    cv2.circle(image_draw, (round(landmarks[num][0]), round(landmarks[num][1])), 2, (0, 255, 0), -1)
cv2.imwrite('result.png', image_draw)

结果展示如下:测试数据图片路径
在这里插入图片描述
从多次搭建的经验来看,建议在搭建模型相关的内容的时候,优先选择阿里云的相关服务,很多东西阿里云的容器云已经提供底层技术,可以很快的使用modelscope提供的操作内容进行快速的模型搭建。


网站公告

今日签到

点亮在社区的每一天
去签到