Age prediction javascript is an app that uses the machine learning model of opencv and tensorflow JS to predict the Age of a person using face recognition. It is solely built by using an open-source model of TFjs

Code for Age Prediction using JS

This project appears to be a web-based application that uses OpenCV.js and TensorFlow.js for some form of image or video processing.

|

25+ More Javascript Projects for beginners, click here to learn more https://pratikpathak.com/top-javascript-projects-with-source-code-github/

More about index.html – Travel India

The HTML structure includes a <video> element for displaying a video stream (likely from a webcam given the id “cam_input”) and a <canvas> element for displaying the processed output.

The project uses several JavaScript files:

  • utils.js is likely a utility script that provides helper functions used in the project.
  • opencv.js is the main OpenCV.js library, which provides a wide range of image and video processing functions.
  • tf.min.js is the TensorFlow.js library, which provides machine learning capabilities.
  • script.js is likely the main script for the application, which uses the above libraries to implement the specific functionality of the project.

The CSS within the <style> tags positions the canvas and video elements, and styles the body of the page

More about script.js – Travel India

The script.js file provides the functionality for a web-based application that uses OpenCV.js and TensorFlow.js for real-time face detection and emotion prediction from a webcam feed.

Here’s a breakdown of the JavaScript code:

  • openCvReady() is the function that will be executed when the OpenCV.js library is loaded.
  • Inside openCvReady(), the cv["onRuntimeInitialized"] function is defined to run once the OpenCV.js runtime is initialized.
  • The video from the webcam is accessed using navigator.mediaDevices.getUserMedia and displayed in the “cam_input” video element.
  • Several OpenCV.js objects are created to hold the video frames (srcdstgraycap), detected faces (faces), and the face classifier (classifier).
  • The Haar cascade face detector is loaded from an XML file using utils.createFileFromUrl and classifier.load.
  • The TensorFlow.js model is loaded from a JSON file using tf.loadLayersModel.
  • processVideo() is a function that is called repeatedly to process each frame of the video. It reads a frame from the video, converts it to grayscale, detects faces in the frame using the Haar cascade classifier, and for each detected face, it extracts the region of interest (ROI), resizes it, and feeds it to the TensorFlow.js model for emotion prediction. The predicted emotion is then drawn on the frame, and the processed frame is displayed in the “canvas_output” canvas element.
  • processVideo() is scheduled to run repeatedly at a rate of 30 frames per second (FPS).

This script enables the application to perform real-time face detection and emotion prediction from a webcam feed.

Categorized in: