Skip to content

Commit

Permalink
agregar docs
Browse files Browse the repository at this point in the history
  • Loading branch information
montoyamoraga committed Nov 19, 2024
1 parent 5b3a839 commit aeabcbe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 77 deletions.
80 changes: 4 additions & 76 deletions 05-SofiaEct/clase-14/README.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,9 @@
# clase-14

´´´javascript
<div>Teachable Machine Pose Model</div>
<button type="button" onclick="init()">Start</button>
<div><canvas id="canvas"></canvas></div>
<div id="label-container"></div>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]/dist/tf.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@teachablemachine/[email protected]/dist/teachablemachine-pose.min.js"></script>
<script type="text/javascript">
// More API functions here:
// https://github.com/googlecreativelab/teachablemachine-community/tree/master/libraries/pose
enlace a la web funcionando

// the link to your model provided by Teachable Machine export panel
const URL = "./my_model/";
let model, webcam, ctx, labelContainer, maxPredictions;
<https://disenoudp.github.io/dis8637-2024-2/05-SofiaEct/clase-14/ml5Manos>

async function init() {
const modelURL = URL + "model.json";
const metadataURL = URL + "metadata.json";
documentación

// load the model and metadata
// Refer to tmImage.loadFromFiles() in the API to support files from a file picker
// Note: the pose library adds a tmPose object to your window (window.tmPose)
model = await tmPose.load(modelURL, metadataURL);
maxPredictions = model.getTotalClasses();

// Convenience function to setup a webcam
const size = 200;
const flip = true; // whether to flip the webcam
webcam = new tmPose.Webcam(size, size, 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 = size; canvas.height = size;
ctx = canvas.getContext("2d");
labelContainer = document.getElementById("label-container");
for (let i = 0; i < maxPredictions; i++) { // and class labels
labelContainer.appendChild(document.createElement("div"));
}
}

async function loop(timestamp) {
webcam.update(); // update the webcam frame
await predict();
window.requestAnimationFrame(loop);
}

async function predict() {
// Prediction #1: run input through posenet
// estimatePose can take in an image, video or canvas html element
const { pose, posenetOutput } = await model.estimatePose(webcam.canvas);
// Prediction 2: run input through teachable machine classification model
const prediction = await model.predict(posenetOutput);

for (let i = 0; i < maxPredictions; i++) {
const classPrediction =
prediction[i].className + ": " + prediction[i].probability.toFixed(2);
labelContainer.childNodes[i].innerHTML = classPrediction;
}

// finally draw the poses
drawPose(pose);
}

function drawPose(pose) {
if (webcam.canvas) {
ctx.drawImage(webcam.canvas, 0, 0);
// draw the keypoints and skeleton
if (pose) {
const minPartConfidence = 0.5;
tmPose.drawKeypoints(pose.keypoints, minPartConfidence, ctx);
tmPose.drawSkeleton(pose.keypoints, minPartConfidence, ctx);
}
}
}
</script>
´´´
![ocho manos](./ochoManos.jpg)
2 changes: 1 addition & 1 deletion examen/grupo-03/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

* 04 - Karen Espinoza Maciel
* 06 - Nora Flores Ávila
* 13 Ivo Pereira Giles
* 13 - Ivo Pereira Giles

0 comments on commit aeabcbe

Please sign in to comment.