Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions front-end/assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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 () => {
Expand Down Expand Up @@ -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"
})

}
11 changes: 8 additions & 3 deletions front-end/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<html>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mask Detection</title>
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
<meta name="theme-color" content="#FFFFFF">
<meta name="description" content="Face Mask Detection Web App">

<link rel="apple-touch-icon" href="./assets/images/apple-touch-icon.png">
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon">
<link rel="manifest" href="./manifest.json">
<!-- Load the latest version of TensorFlow.js -->
<link rel="stylesheet" href="./assets/css/style.css" />

<title>Mask Detection</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/mobilenet"></script>
</head>
Expand Down
7 changes: 2 additions & 5 deletions front-end/sw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const CACHE = "content-v1"
const CACHE = "content-v2"
const OFFLINE = "/offline.html"

const AUTO_CACHE = [OFFLINE, "/"]
Expand Down Expand Up @@ -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))
}

Expand Down