Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@mediapipe/tasks-vision
Advanced tools
@mediapipe/tasks-vision is a powerful npm package that provides a suite of vision-based machine learning tools. It allows developers to integrate advanced computer vision functionalities such as object detection, face detection, hand tracking, and more into their web applications.
Object Detection
This feature allows you to detect objects within an image. The code sample demonstrates how to initialize the object detector and use it to detect objects in a given image.
const vision = require('@mediapipe/tasks-vision');
const objectDetector = new vision.ObjectDetector();
objectDetector.detect(image).then(predictions => {
console.log(predictions);
});
Face Detection
This feature enables face detection within an image. The code sample shows how to initialize the face detector and use it to detect faces in a given image.
const vision = require('@mediapipe/tasks-vision');
const faceDetector = new vision.FaceDetector();
faceDetector.detect(image).then(predictions => {
console.log(predictions);
});
Hand Tracking
This feature allows for real-time hand tracking in video streams. The code sample demonstrates how to initialize the hand tracker and use it to track hands in a video.
const vision = require('@mediapipe/tasks-vision');
const handTracker = new vision.HandTracker();
handTracker.track(video).then(predictions => {
console.log(predictions);
});
face-api.js is a JavaScript library for face detection and face recognition in the browser. It provides functionalities similar to @mediapipe/tasks-vision's face detection but focuses more on facial recognition and expression analysis.
TensorFlow.js is a library for machine learning in JavaScript. It allows you to build and train models in the browser and on Node.js. While it provides a broader range of machine learning functionalities, it can be used to implement vision-based tasks similar to those in @mediapipe/tasks-vision.
OpenCV.js is a JavaScript binding for OpenCV, a popular computer vision library. It offers a wide range of computer vision functionalities, including object detection, face detection, and more, similar to @mediapipe/tasks-vision.
This package contains the vision tasks for MediaPipe.
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.
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.
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);
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,
"https://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.
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.
The MediaPipe Holistic Landmarker task task lets you combine components of the pose, face, and hand landmarkers to create a complete landmarker for the human body.
const vision = await FilesetResolver.forVisionTasks(
"https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision/wasm"
);
const holisticLandmarker = await HolisticLandmarker.createFromModelPath(vision,
"https://storage.googleapis.com/mediapipe-models/holistic_landmarker/holistic_landmarker/float16/1/hand_landmark.task"
);
const image = document.getElementById("image") as HTMLImageElement;
const landmarks = holisticLandmarker.detect(image);
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.
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);
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.
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.
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.
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.
FAQs
MediaPipe Vision Tasks
The npm package @mediapipe/tasks-vision receives a total of 146,066 weekly downloads. As such, @mediapipe/tasks-vision popularity was classified as popular.
We found that @mediapipe/tasks-vision demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.