mediapipe/mediapipe/tasks/web/vision
MediaPipe Team bc035d9146 This will fix the multiple typos in the tasks files.
PiperOrigin-RevId: 534679277
2023-05-23 21:49:34 -07:00
..
core Add iOS support for MPMask 2023-05-22 13:00:05 -07:00
face_detector Use empty keypoint array for Detection if no keypoints are detected 2023-05-23 15:10:00 -07:00
face_landmarker Inline constants for FaceLandmarksConnections 2023-05-08 12:58:18 -07:00
face_stylizer This will fix the multiple typos in the tasks files. 2023-05-23 21:49:34 -07:00
gesture_recognizer Update tests and demos to call "close". 2023-04-27 18:58:57 -07:00
hand_landmarker Update tests and demos to call "close". 2023-04-27 18:58:57 -07:00
image_classifier Update tests and demos to call "close". 2023-04-27 18:58:57 -07:00
image_embedder Update tests and demos to call "close". 2023-04-27 18:58:57 -07:00
image_segmenter This will fix the multiple typos in the tasks files. 2023-05-23 21:49:34 -07:00
interactive_segmenter Add quality scores to Segmenter tasks 2023-05-23 11:37:26 -07:00
object_detector Use empty keypoint array for Detection if no keypoints are detected 2023-05-23 15:10:00 -07:00
pose_landmarker Add .close() method to ImageSegmenterResult/InteractiveSegmenterResult/PoseLandmarkerResult 2023-05-10 12:37:48 -07:00
BUILD Create a MediaPipe Mask Type 2023-05-05 19:23:43 -07:00
index.ts Inline constants for FaceLandmarksConnections 2023-05-08 12:58:18 -07:00
README.md Update links in README.md 2023-05-16 10:45:30 -07:00
types.ts Simplify MPMask by removing the Type Enums from the public API 2023-05-06 10:26:13 -07:00

MediaPipe Tasks Vision Package

This package contains the vision tasks for MediaPipe.

Face Detector

The MediaPipe Face Detector task lets you detect the presence and location of faces within images or videos.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const faceDetector = await FaceDetector.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/face_detector/blaze_face_short_range/float16/1/blaze_face_short_range.tflite"
);
const image = document.getElementById("image") as HTMLImageElement;
const detections = faceDetector.detect(image);

For more information, refer to the Face Detector documentation.

Face Landmarker

The MediaPipe Face Landmarker task lets you detect the landmarks of faces in an image. You can use this Task to localize key points of a face and render visual effects over the faces.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const faceLandmarker = await FaceLandmarker.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task`"
);
const image = document.getElementById("image") as HTMLImageElement;
const landmarks = faceLandmarker.detect(image);

For more information, refer to the Face Landmarker documentation.

Face Stylizer

The MediaPipe Face Stylizer lets you perform face stylization on images.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const faceStylizer = await FaceStylizer.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/face_stylizer/blaze_face_stylizer/float32/1/blaze_face_stylizer.task"
);
const image = document.getElementById("image") as HTMLImageElement;
const stylizedImage = faceStylizer.stylize(image);

Gesture Recognizer

The MediaPipe Gesture Recognizer task lets you recognize hand gestures in real time, and provides the recognized hand gesture results along with the landmarks of the detected hands. You can use this task to recognize specific hand gestures from a user, and invoke application features that correspond to those gestures.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const gestureRecognizer = await GestureRecognizer.createFromModelPath(vision,
    "hhttps://storage.googleapis.com/mediapipe-models/gesture_recognizer/gesture_recognizer/float16/1/gesture_recognizer.task"
);
const image = document.getElementById("image") as HTMLImageElement;
const recognitions = gestureRecognizer.recognize(image);

For more information, refer to the Gesture Recognizer documentation.

Hand Landmarker

The MediaPipe Hand Landmarker task lets you detect the landmarks of the hands in an image. You can use this Task to localize key points of the hands and render visual effects over the hands.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const handLandmarker = await HandLandmarker.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/hand_landmarker/hand_landmarker/float16/1/hand_landmarker.task"
);
const image = document.getElementById("image") as HTMLImageElement;
const landmarks = handLandmarker.detect(image);

For more information, refer to the Hand Landmarker documentation.

Image Classifier

The MediaPipe Image Classifier task lets you perform classification on images. You can use this task to identify what an image represents among a set of categories defined at training time.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const imageClassifier = await ImageClassifier.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/image_classifier/efficientnet_lite0/float32/1/efficientnet_lite0.tflite"
);
const image = document.getElementById("image") as HTMLImageElement;
const classifications = imageClassifier.classify(image);

For more information, refer to the Image Classifier documentation.

Image Embedder

The MediaPipe Image Embedder extracts embeddings from an image.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const imageEmbedder = await ImageEmbedder.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/image_embedder/mobilenet_v3_small/float32/1/mobilenet_v3_small.tflite"
);
const image = document.getElementById("image") as HTMLImageElement;
const embeddings = imageSegmenter.embed(image);

Image Segmenter

The MediaPipe Image Segmenter lets you segment an image into categories.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const imageSegmenter = await ImageSegmenter.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/image_segmenter/deeplab_v3/float32/1/deeplab_v3.tflite"
);
const image = document.getElementById("image") as HTMLImageElement;
imageSegmenter.segment(image, (masks, width, height) => {
  ...
});

For more information, refer to the Image Segmenter documentation.

Interactive Segmenter

The MediaPipe Interactive Segmenter lets you select a region of interest to segment an image by.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const interactiveSegmenter = await InteractiveSegmenter.createFromModelPath(
    vision,
    "https://storage.googleapis.com/mediapipe-models/interactive_segmenter/magic_touch/float32/1/magic_touch.tflite"
);
const image = document.getElementById("image") as HTMLImageElement;
interactiveSegmenter.segment(image, { keypoint: { x: 0.1, y: 0.2 } },
    (masks, width, height) => { ... }
);

For more information, refer to the Interactive Segmenter documentation.

Object Detector

The MediaPipe Object Detector task lets you detect the presence and location of multiple classes of objects within images or videos.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const objectDetector = await ObjectDetector.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/object_detector/efficientdet_lite0/float16/1/efficientdet_lite0.tflite"
);
const image = document.getElementById("image") as HTMLImageElement;
const detections = objectDetector.detect(image);

For more information, refer to the Object Detector documentation.

Pose Landmarker

The MediaPipe Pose Landmarker task lets you detect the landmarks of body poses in an image. You can use this Task to localize key points of a pose and render visual effects over the body.

const vision = await FilesetResolver.forVisionTasks(
    "https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const poseLandmarker = await PoseLandmarker.createFromModelPath(vision,
    "https://storage.googleapis.com/mediapipe-models/pose_landmarker/pose_landmarker_lite/float16/1/pose_landmarker_lite.task
);
const image = document.getElementById("image") as HTMLImageElement;
const landmarks = poseLandmarker.detect(image);

For more information, refer to the Pose Landmarker documentation.