Skip to content

Commit

Permalink
model done
Browse files Browse the repository at this point in the history
  • Loading branch information
dikwickley committed Nov 21, 2020
1 parent 5ff0875 commit fae17e7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion TestFolder/TestTeachableModel/my_model/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"tfjsVersion":"1.3.1","tmVersion":"0.8.6","packageVersion":"0.8.6","packageName":"@teachablemachine/pose","timeStamp":"2020-11-21T15:53:02.597Z","userMetadata":{},"modelName":"my-pose-model","labels":["Good Posture","Bad Posture","Close to screen","Holding Phone"],"modelSettings":{"posenet":{"architecture":"MobileNetV1","outputStride":16,"inputResolution":257,"multiplier":0.75}}}
{"tfjsVersion":"1.3.1","tmVersion":"0.8.6","packageVersion":"0.8.6","packageName":"@teachablemachine/pose","timeStamp":"2020-11-21T18:30:15.108Z","userMetadata":{},"modelName":"my-pose-model","labels":["good posture","bad posture","near screen"],"modelSettings":{"posenet":{"architecture":"MobileNetV1","outputStride":16,"inputResolution":257,"multiplier":0.75}}}
2 changes: 1 addition & 1 deletion TestFolder/TestTeachableModel/my_model/model.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"modelTopology":{"class_name":"Sequential","config":{"name":"sequential_6","layers":[{"class_name":"Dense","config":{"units":100,"activation":"relu","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_in","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense3","trainable":true,"batch_input_shape":[null,14739],"dtype":"float32"}},{"class_name":"Dropout","config":{"rate":0.5,"noise_shape":null,"seed":null,"name":"dropout_Dropout1","trainable":true}},{"class_name":"Dense","config":{"units":4,"activation":"softmax","use_bias":false,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_in","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense4","trainable":true}}]},"keras_version":"tfjs-layers 1.3.1","backend":"tensor_flow.js"},"weightsManifest":[{"paths":["weights.bin"],"weights":[{"name":"dense_Dense3/kernel","shape":[14739,100],"dtype":"float32"},{"name":"dense_Dense3/bias","shape":[100],"dtype":"float32"},{"name":"dense_Dense4/kernel","shape":[100,4],"dtype":"float32"}]}]}
{"modelTopology":{"class_name":"Sequential","config":{"name":"sequential_2","layers":[{"class_name":"Dense","config":{"units":100,"activation":"relu","use_bias":true,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_in","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense1","trainable":true,"batch_input_shape":[null,14739],"dtype":"float32"}},{"class_name":"Dropout","config":{"rate":0.5,"noise_shape":null,"seed":null,"name":"dropout_Dropout1","trainable":true}},{"class_name":"Dense","config":{"units":3,"activation":"softmax","use_bias":false,"kernel_initializer":{"class_name":"VarianceScaling","config":{"scale":1,"mode":"fan_in","distribution":"normal","seed":null}},"bias_initializer":{"class_name":"Zeros","config":{}},"kernel_regularizer":null,"bias_regularizer":null,"activity_regularizer":null,"kernel_constraint":null,"bias_constraint":null,"name":"dense_Dense2","trainable":true}}]},"keras_version":"tfjs-layers 1.3.1","backend":"tensor_flow.js"},"weightsManifest":[{"paths":["weights.bin"],"weights":[{"name":"dense_Dense1/kernel","shape":[14739,100],"dtype":"float32"},{"name":"dense_Dense1/bias","shape":[100],"dtype":"float32"},{"name":"dense_Dense2/kernel","shape":[100,3],"dtype":"float32"}]}]}
Binary file modified TestFolder/TestTeachableModel/my_model/weights.bin
Binary file not shown.
Binary file added assets/img/training model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 19 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
// Convenience function to setup a webcam
const size = 200;
const flip = true; // whether to flip the webcam
webcam = new tmPose.Webcam(600, 400, flip); // width, height, flip
webcam = new tmPose.Webcam(800, 600, flip); // width, height, flip
await webcam.setup(); // request access to the webcam
await webcam.play();
window.requestAnimationFrame(loop);

// append/get elements to the DOM
const canvas = document.getElementById("canvas");
canvas.width = 600; canvas.height = 400;
canvas.width = 800; canvas.height = 600;
ctx = canvas.getContext("2d");
labelContainer = document.getElementById("label-container");
for (let i = 0; i < maxPredictions; i++) { // and class labels
Expand Down Expand Up @@ -107,7 +107,7 @@
// If it's okay let's create a notification
var title = "Posture";
icon = 'https://homepages.cae.wisc.edu/~ece533/images/airplane.png';
var body = "Your posture seems incorrect. Please sit in correctly and click this notification";
var body = message +". Please sit in correctly and click this notification";
var notification = new Notification(title, { body, icon });


Expand All @@ -133,7 +133,7 @@
}
function checkPosture(posturegroup){
//group
// console.log(group)
console.log(group)
goodposture = (posturegroup.reduce((sum, data) =>{
return sum + data[0].probability
},0)/100).toFixed(3)
Expand All @@ -143,19 +143,28 @@
nearscreen = (posturegroup.reduce((sum, data) =>{
return sum + data[2].probability
},0)/100).toFixed(3)
mobile = (posturegroup.reduce((sum, data) =>{
return sum + data[3].probability
},0)/100).toFixed(3)

// console.log('good: ',goodposture,' bad: ', badposture)
// document.getElementById('good').innerHTML = 'Good: ' + goodposture
// document.getElementById('bad').innerHTML = 'Bad: ' + badposture

if(badposture >= 0.98){
console.log({goodposture, badposture,nearscreen})

if(badposture >= 0.90){
// console.log('bad posture')
toggle= false;
group = []
notifyMe("Correct your posture")
}

if(nearscreen >= 0.90){
// console.log('bad posture')
toggle= false;
group = []
notifyMe("straighten the fuck up")
notifyMe("get away from screen")
}


}

function drawPose(pose) {
Expand Down Expand Up @@ -207,7 +216,7 @@ <h4>Have the online classes affected you too?</h4> -->

<!-- Main screen -->
<div id="screen">
<div><canvas id="canvas" style="border: 1px solid black;""></canvas></div>
<div><canvas id="canvas" style="border: 1px solid black;"></canvas></div>
<div>
<!-- <h1 id="result"><span id="good" class="text-success"></span> | <span id="bad" class="text-danger"></span></h1> -->
</div>
Expand Down

0 comments on commit fae17e7

Please sign in to comment.