diff --git a/package-lock.json b/package-lock.json index bf6e267..41b0e8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3495,15 +3495,10 @@ "resolved": "https://registry.npmjs.org/@tensorflow-models/blazeface/-/blazeface-0.0.5.tgz", "integrity": "sha512-bIMJDV2CD8rr7v9OrIDdDZVh9sbk0EhlZdHaDFpgWUw3Lp21wUN7GSifOJVE5hV2ngmpzM+J12OH8bG1GZoDag==" }, - "@tensorflow-models/body-pix": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/@tensorflow-models/body-pix/-/body-pix-2.0.5.tgz", - "integrity": "sha512-zEke/JjGajqZ00b1X4KVq2yevSfl6HxysDnM8WLHVARrbTbCo3RliZZ0m+AuM/q+UASgmzpiyrEXQYUmmy+H3g==" - }, - "@tensorflow-models/facemesh": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@tensorflow-models/facemesh/-/facemesh-0.0.4.tgz", - "integrity": "sha512-xSsFxYf3NNp96r//HudAPfkPu8P+9Ip8IAECOYY0DmzOKSErw+O1iLgJEl7+DvkYhbdTjb1uAxQIU2LNpJmjgw==", + "@tensorflow-models/face-landmarks-detection": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/@tensorflow-models/face-landmarks-detection/-/face-landmarks-detection-0.0.2.tgz", + "integrity": "sha512-dgniPMSchWwj2DBqqlvDA2NBMY5oDaQF1vUjz9IQQCXO4qtA0Q0z0ntjO7K+sJuNwSP3qoDeespxuEhBgpQgGg==", "requires": { "@tensorflow-models/blazeface": "0.0.5", "rimraf": "^3.0.2" diff --git a/package.json b/package.json index 514d5ee..d6e3da6 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@tensorflow-models/body-pix": "^2.0.5", - "@tensorflow-models/facemesh": "0.0.4", + "@tensorflow-models/face-landmarks-detection": "0.0.2", "@tensorflow/tfjs": "^2.3.0", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", diff --git a/src/App.js b/src/App.js index e2a20ad..5d904f6 100644 --- a/src/App.js +++ b/src/App.js @@ -9,10 +9,14 @@ // Face Mesh - https://github.com/tensorflow/tfjs-models/tree/master/facemesh -import React, { useRef } from "react"; +import React, { useRef, useEffect } from "react"; import "./App.css"; import * as tf from "@tensorflow/tfjs"; -import * as facemesh from "@tensorflow-models/facemesh"; +// OLD MODEL +//import * as facemesh from "@tensorflow-models/facemesh"; + +// NEW MODEL +import * as facemesh from "@tensorflow-models/face-landmarks-detection"; import Webcam from "react-webcam"; import { drawMesh } from "./utilities"; @@ -22,14 +26,16 @@ function App() { // Load posenet const runFacemesh = async () => { - const net = await facemesh.load({ - inputResolution: { width: 640, height: 480 }, - scale: 0.8, - }); - // + // OLD MODEL + // const net = await facemesh.load({ + // inputResolution: { width: 640, height: 480 }, + // scale: 0.8, + // }); + // NEW MODEL + const net = await facemesh.load(facemesh.SupportedPackages.mediapipeFacemesh); setInterval(() => { detect(net); - }, 100); + }, 10); }; const detect = async (net) => { @@ -52,16 +58,19 @@ function App() { canvasRef.current.height = videoHeight; // Make Detections - const face = await net.estimateFaces(video); + // OLD MODEL + // const face = await net.estimateFaces(video); + // NEW MODEL + const face = await net.estimateFaces({input:video}); console.log(face); // Get canvas context const ctx = canvasRef.current.getContext("2d"); - drawMesh(face, ctx); + requestAnimationFrame(()=>{drawMesh(face, ctx)}); } }; - runFacemesh(); + useEffect(()=>{runFacemesh()}, []); return (