license import { FaceDetector } from './face_detector' ; import { load as loadMediaPipeFaceMeshMediaPipeDetector } from './mediapipe/detector' ; import { MediaPipeFaceMeshMediaPipeModelConfig , MediaPipeFaceMeshModelConfig } from './mediapipe/types' ; import { SupportedModels } from './types' ; param model param modelConfig export async function createDetector ( model , modelConfig ? ) { switch ( model ) { case SupportedModels . MediaPipeFaceMesh : const config = modelConfig as MediaPipeFaceMeshModelConfig ; let runtime ; if ( config != null ) { if ( config . runtime === 'tfjs' ) { throw new Error ( 'TFJS runtime is not yet supported.' ) ; } if ( config . runtime === 'mediapipe' ) { return loadMediaPipeFaceMeshMediaPipeDetector ( config as MediaPipeFaceMeshMediaPipeModelConfig ) ; } runtime = config . runtime ; } throw new Error ( `Expect modelConfig.runtime to be either 'tfjs' ` + `or 'mediapipe', but got ${ runtime }` ) ; default : throw new Error ( `${ model } is not a supported model name.` ) ; } }