【增加模型快捷加载方法】
This commit is contained in:
@ -2,6 +2,24 @@ import { Mat } from "../../cv/mat";
|
||||
import { convertImage } from "../common/processors";
|
||||
import { FaceRecognition, FaceRecognitionPredictOption } from "./common";
|
||||
|
||||
const MODEL_URL_CONFIG_ARC_FACE = {
|
||||
INSIGHTFACE_ARCFACE_R100_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/ms1mv3_arcface_r100.onnx`,
|
||||
INSIGHTFACE_ARCFACE_R50_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/ms1mv3_arcface_r50.onnx`,
|
||||
INSIGHTFACE_ARCFACE_R34_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/ms1mv3_arcface_r34.onnx`,
|
||||
INSIGHTFACE_ARCFACE_R18_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/ms1mv3_arcface_r18.onnx`,
|
||||
};
|
||||
const MODEL_URL_CONFIG_COS_FACE = {
|
||||
INSIGHTFACE_COSFACE_R100_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/glint360k_cosface_r100.onnx`,
|
||||
INSIGHTFACE_COSFACE_R50_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/glint360k_cosface_r50.onnx`,
|
||||
INSIGHTFACE_COSFACE_R34_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/glint360k_cosface_r34.onnx`,
|
||||
INSIGHTFACE_COSFACE_R18_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/glint360k_cosface_r18.onnx`,
|
||||
};
|
||||
const MODEL_URL_CONFIG_PARTIAL_FC = {
|
||||
INSIGHTFACE_PARTIALFC_R100_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/partial_fc_glint360k_r100.onnx`,
|
||||
INSIGHTFACE_PARTIALFC_R50_ONNX: `https://www.modelscope.cn/models/luyizhi/basic_cv/resolve/master/faceid/insightface/partial_fc_glint360k_r50.onnx`,
|
||||
};
|
||||
|
||||
|
||||
export class Insightface extends FaceRecognition {
|
||||
|
||||
public async doPredict(image: Mat, option?: FaceRecognitionPredictOption): Promise<number[]> {
|
||||
@ -24,9 +42,21 @@ export class Insightface extends FaceRecognition {
|
||||
|
||||
}
|
||||
|
||||
export class ArcFace extends Insightface { }
|
||||
export class ArcFace extends Insightface {
|
||||
public static async load(type?: keyof typeof MODEL_URL_CONFIG_ARC_FACE) {
|
||||
return this.cacheModel(MODEL_URL_CONFIG_ARC_FACE[type ?? "INSIGHTFACE_ARCFACE_R100_ONNX"], { createModel: true }).then(r => r.model);
|
||||
}
|
||||
}
|
||||
|
||||
export class CosFace extends Insightface { }
|
||||
export class CosFace extends Insightface {
|
||||
public static async load(type?: keyof typeof MODEL_URL_CONFIG_COS_FACE) {
|
||||
return this.cacheModel(MODEL_URL_CONFIG_COS_FACE[type ?? "INSIGHTFACE_COSFACE_R100_ONNX"], { createModel: true }).then(r => r.model);
|
||||
}
|
||||
}
|
||||
|
||||
export class PartialFC extends Insightface { }
|
||||
export class PartialFC extends Insightface {
|
||||
public static async load(type?: keyof typeof MODEL_URL_CONFIG_PARTIAL_FC) {
|
||||
return this.cacheModel(MODEL_URL_CONFIG_PARTIAL_FC[type ?? "INSIGHTFACE_PARTIALFC_R100_ONNX"], { createModel: true }).then(r => r.model);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user