我正在尝试注册一个基于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
…我想根据中的说明进行部署:
如何在ML Studio中部署这种基于OpenCV的人脸标记模型
谢谢你, c级
您可能希望注册您的模型文件(lbfmodel.yml)和所需的源文件(在本例中是landmarker.py)——通过将model.register命令指向一个目录,这是最简单的方法
这些可以作为导入和加载从驱动程序文件引用
相关问题 更多 >
编程相关推荐