The steps for this recipe are as follows:
- In the index.js file, add a GetData function that gets the data from data.json:
async function GetData(){
$.get( "/data.json", function( data ) {
$( "#data" ).text( data["dat"] );
predict(data["dat"])
});
}
- Make a function that pulls in the model and evaluates the data:
async function predict(dat)
{
const model = await tf.loadLayersModel('/tfjs_model/model.json');
console.log(model)
dat = tf.tensor3d(dat, [1, 50, 25] )
dat[0] = null
console.log(dat)
var pred = model.predict( dat)
const values = pred.dataSync();
let result = "Needs Maintenance"
if(values[0] < .8)
result = "Does not need Maintenance"
$('#needed').html(result )
}
- Create an index.html file that will call your js file:
<!DOCTYPE html>
<html>
<head>
<title>Model</title>
<script src="https://cdn.jsdelivr.net/npm...