无法在Azure机器学习服务上注册自定义模型(基于OpenCV)

2024-10-03 04:33:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试注册一个基于cv2.face.createFacemarkLBF的模型,但没有成功

我从这样一门课开始:

import cv2
import numpy as np
from pprint import pprint as pp
from lib.fsclib import logger

LBF_MODEL = model_file = "lbfmodel.yml"

class Landmarker:
    def __init__(self):
        self.logger = logger
        self.landmarker = None

    def get_img_gray(self,img):
        return cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

    def process_landmarks(self, raw_landmarks):
        return raw_landmarks

    def get_landmarks(self, img_gray, face_coords):
        pass

class MyLandmarker(Landmarker):
    def __init__(self, model=LBF_MODEL):
        super(MyLandmarker).__init__()
        logger.info("Initializing FACEMARK with model: %s"%model)
        self.landmarker = cv2.face.createFacemarkLBF()
        self.landmarker.loadModel(model)

    def get_landmarks(self,image, face):
        landmarks = None
        try:
            ok, landmarks = self.landmarker.fit(self.get_img_gray(image), face)
        except Exception as e:
            logger.error("Error on class - %s - landmarking failed - %s"%(self.__class__.__name__,str(e)))
        return landmarks

…我想根据中的说明进行部署:

https://docs.microsoft.com/en-us/azure/machine-learning/service/how-to-deploy-and-where#registermodel

如何在ML Studio中部署这种基于OpenCV的人脸标记模型

谢谢你, c级


Tags: importselfimggetmodelinitdefas