Open romario32 opened 4 years ago
I found the issue, it seems like the model doesn't work when ml5.neuralNetwork(options).save(poseID); is given a string.
I came here with google search.
romario got it. If anybody gets the same error "Weight file with basename is not provided" the solution is easy : do not save your model with a custom name => USE model.save(), NOT model.save("myName")
Then us the newly generated files "model.weights.bin"
Works like a charm.
Code
` let trained = false; let collecting = false; let video; let poseNet; let pose; let skeleton; let brain; let state = 'waiting'; let targeLabel = 'pose'; let poselist let poseLabel = "Do your pose"; let count = 0;
function setup() { canvas = createCanvas(640, 480); canvas.parent('sketch'); video = createCapture(VIDEO); video.hide(); poseNet = ml5.poseNet(video, modelLoaded); poseNet.on('pose', gotPoses); let options = { inputs: 34, outputs: 2, task: 'classification', debug: true }
}
function wrong() { doPose('F'); }
function correct() { doPose('P'); } //login Mode function brainLoaded() { console.log('pose classification ready!'); classifyPose(); }
function classifyPose() { if (pose) { let inputs = []; for (let i = 0; i < pose.keypoints.length; i++) { let x = pose.keypoints[i].position.x; let y = pose.keypoints[i].position.y; inputs.push(x); inputs.push(y); } brain.classify(inputs, gotResult); } else { setTimeout(classifyPose, 100); } }
function gotResult(error, results) {
}
//signup Mode function gotPoses(poses) { // console.log(poses); if (poses.length > 0) { pose = poses[0].pose; skeleton = poses[0].skeleton; if (state == 'collecting') { let inputs = []; for (let i = 0; i < pose.keypoints.length; i++) { let x = pose.keypoints[i].position.x; let y = pose.keypoints[i].position.y; inputs.push(x); inputs.push(y); } let target = [targetLabel]; brain.addData(inputs, target); } } }
function doPose(type) { targetLabel = type; console.log(targetLabel); timer('waitTime'); setTimeout(function () { timer('poseTimer'); console.log('collecting'); state = 'collecting'; setTimeout(function () { console.log('not collecting'); state = 'waiting'; }, 10000); }, 10000);
}
function trainModel() { // No longer collecting dataa brain.normalizeData(); let options = { epochs: 50 } brain.train(options, finishedTraining); }
function finishedTraining() { console.log('done'); brain.save(poseID); }
//timer function startTimer(duration, display) { var timer = duration, minutes, seconds; var idTime = setInterval(function () { minutes = parseInt(timer / 60, 10) seconds = parseInt(timer % 60, 10);
}
function timer(t) { var fiveMinutes = 10, display = document.querySelector('#' + t); startTimer(fiveMinutes, display); }
function modelLoaded() { console.log('poseNet ready');
}
//skeleton display function draw() { push(); translate(video.width, 0); scale(-1, 1); image(video, 0, 0, video.width, video.height);
} `
I am trying to train a model on one screen and deploy the model on another in laravel. i got the model to train however when I am trying to estimate a pose it won't work. I am plagued by this error:
ml5.min.js:18 Uncaught (in promise) Error: Weight file with basename 'modeltest.weights.bin' is not provided. at ml5.min.js:18 at Array.forEach ()
at t.checkManifestAndWeightFiles (ml5.min.js:18)
at FileReader.o.onload (ml5.min.js:18)