This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.get("/get-next", (req, res) => { | |
let pg_start = Number(req.query.pg_end) | |
let pg_end = Number(pg_start) + 12 | |
res.render("index", { | |
books: books.slice(pg_start, pg_end), | |
pg_start: pg_start, | |
pg_end: pg_end | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const bodyParser = require("body-parser"); | |
const expressHbs = require("express-handlebars"); | |
const books = require("./data/web_book_data.json") | |
const model = require("./model") | |
const app = express(); | |
app.set("views", "./views"); | |
app.set("view engine", "hbs"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function capture() { | |
capturing = true | |
while (capturing) { | |
const img = await webcam.capture(); | |
const predictions = await model.estimateFaces(img); | |
if (predictions.length > 0) { | |
let a = []; b = []; c = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let model; | |
let webcam | |
let webcamElement = document.getElementById("webcam") | |
let capturing = false | |
async function main() { | |
// Load the MediaPipe facemesh model. | |
model = await facemesh.load(); | |
console.log("Model loaded") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script> | |
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/facemesh"></script> | |
<!-- Bootstrap CSS --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function app() { | |
console.log('DownLoading mobilenet..'); | |
// Load the MobileNet pretrained model. | |
base_net = await mobilenet.load(); | |
console.log('Successfully loaded model'); | |
// Create an object from Tensorflow.js data API which could capture image | |
// from the web camera as Tensor. | |
webcam = await tf.data.webcam(webcamElement); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let base_net,webcam; | |
const webcamElement = document.getElementById('webcam'); | |
const classifier = knnClassifier.create(); | |
async function addExample(classId) { | |
// Capture an image from the web camera. | |
const img = await webcam.capture(); | |
// Get the intermediate activation of MobileNet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" | |
integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from tensorflow.keras.datasets.mnist import load_data | |
from tensorflow.keras import Sequential | |
from tensorflow.keras.layers import Dense,Conv2D,MaxPool2D,Flatten,Dropout | |
# load dataset | |
train_data, test_data = load_data() | |
x_train = train_data[0] | |
y_train = train_data[1] | |
x_val = test_data[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Updating model status | |
tstatus = document.getElementById('status') | |
predval = document.getElementById('predval') | |
//Load the CNN Model on page load | |
document.addEventListener('DOMContentLoaded', async () => { | |
await loadModel(); | |
}, false); |