From 8781446633a8017c542de4ebf3c4602b874e958e Mon Sep 17 00:00:00 2001 From: Tharunraj Optimus <59702671+tharunoptimus@users.noreply.github.com> Date: Tue, 18 Jan 2022 22:35:52 +0530 Subject: [PATCH 1/2] Added request animation frame to js Added Manifest to index.html --- front-end/assets/js/app.js | 8 +++++--- front-end/index.html | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/front-end/assets/js/app.js b/front-end/assets/js/app.js index d74912f..9ad3b9b 100644 --- a/front-end/assets/js/app.js +++ b/front-end/assets/js/app.js @@ -3,7 +3,7 @@ let video = document.querySelector("#video") const webcamElement = document.getElementById("webcam") webcamElement.style.display = "none" -const model = tf.loadLayersModel('./model/model.json').then( _ => console.log("CNN Model Loaded")) +const model = tf.loadLayersModel('./model/model.json').then( _ => console.log("MobileNet v2 Model Loaded")) let text = document.getElementById("text") @@ -12,7 +12,7 @@ async function app() { document.querySelector("h1").innerText = "Downloading the Model..." net = await mobilenet.load() - // Create an object from Tensorflow.js data API which could capture image + // Create an object from Tensorflow.js data API which would capture image // from the web camera as Tensor. setInterval(async () => { @@ -93,6 +93,8 @@ function isMasked(value) { maskText.style.display = "none" noMaskText.style.display = "none" - value ? maskText.style.display = "block" : noMaskText.style.display = "block" + requestAnimationFrame(() => { + value ? maskText.style.display = "block" : noMaskText.style.display = "block" + }) } \ No newline at end of file diff --git a/front-end/index.html b/front-end/index.html index 256def3..016af68 100644 --- a/front-end/index.html +++ b/front-end/index.html @@ -1,13 +1,18 @@ - + + - Mask Detection - + + + + + + Mask Detection From 2f821358c5daea4d8e73c13e1e2bf6b953171c1c Mon Sep 17 00:00:00 2001 From: Tharunraj Optimus <59702671+tharunoptimus@users.noreply.github.com> Date: Wed, 23 Mar 2022 07:08:39 +0530 Subject: [PATCH 2/2] Bug Fix: Service worker will cache the model too. --- front-end/sw.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/front-end/sw.js b/front-end/sw.js index f64693d..228f24f 100644 --- a/front-end/sw.js +++ b/front-end/sw.js @@ -1,4 +1,4 @@ -const CACHE = "content-v1" +const CACHE = "content-v2" const OFFLINE = "/offline.html" const AUTO_CACHE = [OFFLINE, "/"] @@ -32,10 +32,7 @@ self.addEventListener("activate", (event) => { }) self.addEventListener("fetch", (event) => { - if ( - !event.request.url.startsWith(self.location.origin) || - event.request.method !== "GET" - ) { + if ( event.request.method !== "GET" ) { return void event.respondWith(fetch(event.request)) }