From 6c38483b3767637587b2503453755664b1a29378 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 7 Sep 2023 11:49:52 -0700 Subject: [PATCH] Add externs to js_library targets PiperOrigin-RevId: 563500180 --- mediapipe/tasks/web/audio/externs.js | 27 +++++ mediapipe/tasks/web/text/externs.js | 33 ++++++ mediapipe/tasks/web/vision/core/mask.ts | 2 +- mediapipe/tasks/web/vision/externs.js | 145 ++++++++++++++++++++++++ 4 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 mediapipe/tasks/web/audio/externs.js create mode 100644 mediapipe/tasks/web/text/externs.js create mode 100644 mediapipe/tasks/web/vision/externs.js diff --git a/mediapipe/tasks/web/audio/externs.js b/mediapipe/tasks/web/audio/externs.js new file mode 100644 index 000000000..114149b8b --- /dev/null +++ b/mediapipe/tasks/web/audio/externs.js @@ -0,0 +1,27 @@ +/** @externs */ + +const AudioClassifier = {}; +AudioClassifier.createFromModelBuffer = function() {}; +AudioClassifier.createFromOptions = function() {}; +AudioClassifier.createFromModelPath = function() {}; +AudioClassifier.classify = function() {}; +AudioClassifier.setDefaultSampleRate = function() {}; +AudioClassifier.setOptions = function() {}; +AudioClassifier.close = function() {}; + +const AudioEmbedder = {}; +AudioEmbedder.createFromModelBuffer = function() {}; +AudioEmbedder.createFromOptions = function() {}; +AudioEmbedder.createFromModelPath = function() {}; +AudioEmbedder.embded = function() {}; +AudioEmbedder.setOptions = function() {}; +AudioEmbedder.cosineSimilarity = function() {}; +AudioEmbedder.setDefaultSampleRate = function() {}; +AudioEmbedder.setOptions = function() {}; +AudioEmbedder.close = function() {}; + +const FilesetResolver = {}; +FilesetResolver.isSimdSupported = function() {}; +FilesetResolver.forAudioTasks = function() {}; +FilesetResolver.forTextTasks = function() {}; +FilesetResolver.forVisionTasks = function() {}; diff --git a/mediapipe/tasks/web/text/externs.js b/mediapipe/tasks/web/text/externs.js new file mode 100644 index 000000000..e293cd851 --- /dev/null +++ b/mediapipe/tasks/web/text/externs.js @@ -0,0 +1,33 @@ +/** @externs */ + +const LanguageDetector = {}; +LanguageDetector.createFromModelBuffer = function() {}; +LanguageDetector.createFromOptions = function() {}; +LanguageDetector.createFromModelPath = function() {}; +LanguageDetector.detect = function() {}; +LanguageDetector.setOptions = function() {}; +LanguageDetector.close = function() {}; + +const TextClassifier = {}; +TextClassifier.createFromModelBuffer = function() {}; +TextClassifier.createFromOptions = function() {}; +TextClassifier.createFromModelPath = function() {}; +TextClassifier.classify = function() {}; +TextClassifier.setOptions = function() {}; +TextClassifier.close = function() {}; + +const TextEmbedder = {}; +TextEmbedder.createFromModelBuffer = function() {}; +TextEmbedder.createFromOptions = function() {}; +TextEmbedder.createFromModelPath = function() {}; +TextEmbedder.embded = function() {}; +TextEmbedder.setOptions = function() {}; +TextEmbedder.cosineSimilarity = function() {}; +TextClassifier.setOptions = function() {}; +TextClassifier.close = function() {}; + +const FilesetResolver = {}; +FilesetResolver.isSimdSupported = function() {}; +FilesetResolver.forTextTasks = function() {}; +FilesetResolver.forTextTasks = function() {}; +FilesetResolver.forVisionTasks = function() {}; diff --git a/mediapipe/tasks/web/vision/core/mask.ts b/mediapipe/tasks/web/vision/core/mask.ts index 9622b638f..396f8cc84 100644 --- a/mediapipe/tasks/web/vision/core/mask.ts +++ b/mediapipe/tasks/web/vision/core/mask.ts @@ -137,7 +137,7 @@ export class MPMask { * Returns the texture format used for writing float textures on this * platform. */ - getTexImage2DFormat(): GLenum { + private getTexImage2DFormat(): GLenum { const gl = this.getGL(); if (!MPMask.texImage2DFormat) { // Note: This is the same check we use in diff --git a/mediapipe/tasks/web/vision/externs.js b/mediapipe/tasks/web/vision/externs.js new file mode 100644 index 000000000..6a1a23249 --- /dev/null +++ b/mediapipe/tasks/web/vision/externs.js @@ -0,0 +1,145 @@ +/** @externs */ + +const DrawingUtils = {}; +DrawingUtils.clamp = function() {}; +DrawingUtils.lerp = function() {}; +DrawingUtils.drawLandmarks = function() {}; +DrawingUtils.drawConnectors = function() {}; +DrawingUtils.drawBoundingBox = function() {}; + +const FaceDetector = {}; +FaceDetector.createFromModelBuffer = function() {}; +FaceDetector.createFromOptions = function() {}; +FaceDetector.createFromModelPath = function() {}; +FaceDetector.detect = function() {}; +FaceDetector.detectForVideo = function() {}; +FaceDetector.setOptions = function() {}; +FaceDetector.close = function() {}; + +const FaceLandmarker = {}; +FaceLandmarker.FACE_LANDMARKS_LIPS = {}; +FaceLandmarker.FACE_LANDMARKS_LEFT_EYE = {}; +FaceLandmarker.FACE_LANDMARKS_LEFT_EYEBROW = {}; +FaceLandmarker.FACE_LANDMARKS_LEFT_IRIS = {}; +FaceLandmarker.FACE_LANDMARKS_RIGHT_EYE = {}; +FaceLandmarker.FACE_LANDMARKS_RIGHT_EYEBROW = {}; +FaceLandmarker.FACE_LANDMARKS_RIGHT_IRIS = {}; +FaceLandmarker.FACE_LANDMARKS_FACE_OVAL = {}; +FaceLandmarker.FACE_LANDMARKS_CONTOURS = {}; +FaceLandmarker.FACE_LANDMARKS_TESSELATION = {}; +FaceLandmarker.createFromModelBuffer = function() {}; +FaceLandmarker.createFromOptions = function() {}; +FaceLandmarker.createFromModelPath = function() {}; +FaceLandmarker.detect = function() {}; +FaceLandmarker.detectForVideo = function() {}; +FaceLandmarker.setOptions = function() {}; +FaceLandmarker.close = function() {}; + +const FaceStylizer = {}; +FaceStylizer.createFromModelBuffer = function() {}; +FaceStylizer.createFromOptions = function() {}; +FaceStylizer.createFromModelPath = function() {}; +FaceStylizer.stylize = function() {}; +FaceStylizer.setOptions = function() {}; +FaceStylizer.close = function() {}; + +const FilesetResolver = {}; +FilesetResolver.isSimdSupported = function() {}; +FilesetResolver.forAudioTasks = function() {}; +FilesetResolver.forTextTasks = function() {}; +FilesetResolver.forVisionTasks = function() {}; + +const GestureRecognizer = {}; +GestureRecognizer.createFromModelBuffer = function() {}; +GestureRecognizer.createFromOptions = function() {}; +GestureRecognizer.createFromModelPath = function() {}; +GestureRecognizer.recognize = function() {}; +GestureRecognizer.recognizeForVideo = function() {}; +GestureRecognizer.setOptions = function() {}; +GestureRecognizer.close = function() {}; + +const HandLandmarker = {}; +HandLandmarker.HAND_CONNECTIONS = {}; +HandLandmarker.createFromModelBuffer = function() {}; +HandLandmarker.createFromOptions = function() {}; +HandLandmarker.createFromModelPath = function() {}; +HandLandmarker.detect = function() {}; +HandLandmarker.detectForVideo = function() {}; +HandLandmarker.setOptions = function() {}; +HandLandmarker.close = function() {}; + +const ImageClassifier = {}; +ImageClassifier.createFromModelBuffer = function() {}; +ImageClassifier.createFromOptions = function() {}; +ImageClassifier.createFromModelPath = function() {}; +ImageClassifier.classify = function() {}; +ImageClassifier.classifyForVideo = function() {}; +ImageClassifier.setOptions = function() {}; +ImageClassifier.close = function() {}; + +const ImageEmbedder = {}; +ImageEmbedder.createFromModelBuffer = function() {}; +ImageEmbedder.createFromOptions = function() {}; +ImageEmbedder.createFromModelPath = function() {}; +ImageEmbedder.embded = function() {}; +ImageEmbedder.embedForVideo = function() {}; +ImageEmbedder.setOptions = function() {}; +ImageEmbedder.cosineSimilarity = function() {}; +ImageEmbedder.close = function() {}; + +const ImageSegmenter = {}; +ImageSegmenter.createFromModelBuffer = function() {}; +ImageSegmenter.createFromOptions = function() {}; +ImageSegmenter.createFromModelPath = function() {}; +ImageSegmenter.segmment = function() {}; +ImageSegmenter.segmentForVideo = function() {}; +ImageSegmenter.setOptions = function() {}; +ImageSegmenter.getLabels = function() {}; +ImageSegmenter.close = function() {}; + +const InteractiveSegmenter = {}; +InteractiveSegmenter.createFromModelBuffer = function() {}; +InteractiveSegmenter.createFromOptions = function() {}; +InteractiveSegmenter.createFromModelPath = function() {}; +InteractiveSegmenter.segmment = function() {}; +InteractiveSegmenter.setOptions = function() {}; +InteractiveSegmenter.close = function() {}; + +const MPImage = {}; +MPImage.hasImageData = function() {}; +MPImage.hasImageBitmap = function() {}; +MPImage.hasWebGLTexture = function() {}; +MPImage.getAsImageData = function() {}; +MPImage.getAsImageBitmap = function() {}; +MPImage.getAsWebGLTexture = function() {}; +MPImage.clone = function() {}; +MPImage.close = function() {}; + +const MPMask = {}; +MPMask.hasUint8Array = function() {}; +MPMask.hasFloat32Array = function() {}; +MPMask.hasWebGLTexture = function() {}; +MPMask.getAsUint8Array = function() {}; +MPMask.getAsFloat32Array = function() {}; +MPMask.getAsWebGLTexture = function() {}; +MPMask.clone = function() {}; +MPMask.close = function() {}; + +const ObjectDetector = {}; +ObjectDetector.createFromModelBuffer = function() {}; +ObjectDetector.createFromOptions = function() {}; +ObjectDetector.createFromModelPath = function() {}; +ObjectDetector.detect = function() {}; +ObjectDetector.detectForVideo = function() {}; +ObjectDetector.setOptions = function() {}; +ObjectDetector.close = function() {}; + +const PoseLandmarker = {}; +PoseLandmarker.POSE_CONNECTIONS = {}; +PoseLandmarker.createFromModelBuffer = function() {}; +PoseLandmarker.createFromOptions = function() {}; +PoseLandmarker.createFromModelPath = function() {}; +PoseLandmarker.detect = function() {}; +PoseLandmarker.detectForVideo = function() {}; +PoseLandmarker.setOptions = function() {}; +PoseLandmarker.close = function() {};