Skip to content

Instantly share code, notes, and snippets.

View risenW's full-sized avatar

Rising Odegua risenW

View GitHub Profile
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
})
});
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");
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 = []
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")
<!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 -->
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);
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
<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">
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]
//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);