【增加模型快捷加载方法】

This commit is contained in:
2025-03-07 10:19:26 +08:00
parent dc94573862
commit 8af5846490
9 changed files with 187 additions and 22 deletions

View File

@ -17,7 +17,17 @@ class PFLDResult extends FaceAlignmentResult {
protected contourPointIndex(): number[] { return [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]; }
}
const MODEL_URL_CONFIG = {
PFLD_106_LITE_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/facealign/pfld-106-lite.onnx`,
PFLD_106_V2_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/facealign/pfld-106-v2.onnx`,
PFLD_106_V3_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/facealign/pfld-106-v3.onnx`,
};
export class PFLD extends Model {
public static async load(type?: keyof typeof MODEL_URL_CONFIG) {
return this.cacheModel(MODEL_URL_CONFIG[type ?? "PFLD_106_LITE_ONNX"], { createModel: true }).then(r => r.model);
}
public predict(image: ImageSource, option?: PFLDPredictOption) { return Model.resolveImage(image, im => this.doPredict(im, option)); }
private async doPredict(image: cv.Mat, option?: PFLDPredictOption) {