Open yehonatanyosefi opened 1 year ago
Hey Miaoye,
You can see my code at: https://github.com/yehonatanyosefi/eramorph/blob/main/src/cmps/Pose.jsx
Feel free to email me for any more questions.
On Tue, Jun 27, 2023, 17:06 Miaoye Que @.***> wrote:
Hi Yehonatan,
Thank you for opening an issue with us! I'm wondering if you can point me to where the code lives or upload a more complete snippet (I'm assuming the code you shared is from asyncToGenerator.js?) so that I can try to reproduce the error?
Miaoye
— Reply to this email directly, view it on GitHub https://github.com/ml5js/ml5-library/issues/1468#issuecomment-1609697896, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5N5RIBUGAH3KQEHBFO7HADXNLZI3ANCNFSM6AAAAAAZMNBREU . You are receiving this because you authored the thread.Message ID: @.***>
React stack traces are the worst. All I can tell is that somewhere inside classifyInternal
(or any of the functions that it calls) there is an Object.keys(something)
on a something
which is not an object.
The only top-level Object.keys
are on meta.inputs
and meta.outputs
. I don't know how those could be undefined
but humor me and add some extra logging. The line we're looking for might be something else really deep in the tree and hard to find.
const classifyPose = async () => {
try {
if (pose && skeleton.length) {
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)
}
console.log('Inputs', inputs);
const meta = brainRef.current.neuralNetworkData.meta;
console.log('Meta', meta);
console.log('meta.inputs', meta.inputs);
console.log('meta.outputs', meta.outputs);
const results = await brainRef.current.classify(inputs);
gotResults(undefined, results);
} else {
// console.log('Pose not found')
setCurrPose('Not found')
posesArray.current = [...posesArray.current, null]
}
handleGameTik()
} catch(e) {
console.log('Caught error', e);
console.trace();
}
}
Sorry for the late reply, I was on a vacation in Rome. Here are the results of the modified classify function: Inputs (34) [329.2766621511734, 232.7027044036509, 338.82978149889044, 221.55281749680813, 315.95720491520626, 221.3593028027724, 354.0813045279061, 235.36775878431268, 294.83786972580253, 236.0488698640222, 380.0362506079767, 315.43611311263146, 258.1640078770975, 306.9329822109831, 423.33587527738933, 422.2171400493221, 212.15757733653027, 393.2147017898263, 419.57896429277116, 500.38656865576365, 221.31209674048517, 470.4224481842398, 355.87284577959707, 505.9700231886096, 260.7915808532952, 494.00144940684277, 361.01693773084116, 581.7396539472884, 249.60313255220998, 576.3485622777085, 362.25384574919826, 571.0491598997598, 245.90564950430903, 566.701991456028] Meta:
meta.inputs undefined
Pose.jsx:177 meta.outputs undefined
Caught error TypeError: Cannot convert undefined or null to object
at Function.keys (
React stack traces are the worst. All I can tell is that somewhere inside classifyInternal https://github.com/ml5js/ml5-library/blob/f80f95aa6b31191ab7e79ff466e8506f5e48a172/src/NeuralNetwork/index.js#L1045 (or any of the functions that it calls) there is an Object.keys(something) on a something which is not an object.
The only top-level Object.keys are on meta.inputs and meta.outputs. I don't know how those could be undefined but humor me and add some extra logging. The line we're looking for might be something else really deep in the tree and hard to find.
const classifyPose = async () => { try { if (pose && skeleton.length) { 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) } console.log('Inputs', inputs); const meta = brainRef.current.neuralNetworkData.meta; console.log('Meta', meta); console.log('meta.inputs', meta.inputs); console.log('meta.outputs', meta.outputs); const results = await brainRef.current.classify(inputs); gotResults(undefined, results); } else { // console.log('Pose not found') setCurrPose('Not found') posesArray.current = [...posesArray.current, null] } handleGameTik() } catch(e) { console.log('Caught error', e); console.trace(); } }
— Reply to this email directly, view it on GitHub https://github.com/ml5js/ml5-library/issues/1468#issuecomment-1610385983, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5N5RIBT6SM4IFVNRAS7UUTXNNYNTANCNFSM6AAAAAAZMNBREU . You are receiving this because you authored the thread.Message ID: @.***>
-- יהונתן יוספי
Okay we are getting somewhere! You’ve confirmed that meta.inputs and meta.outputs are both undefined and that’s what triggers the TypeError.
In looking at your meta object I can see that the info which we need is there but it’s not in the right place. It looks like it’s meta.meta.inputs instead of meta.inputs.
I haven’t got to the root problem yet. That is, why the meta is structured incorrectly. I’ll need to play around more and run your code. It’s either a problem with reading your metadata.json file or it’s a problem with exporting the model which led to an incorrect metadata.json. There probably exists a quick fix where I tell you what to change in the metadata.json file to make it work but that’s a poor solution that doesn’t address why it’s wrong. Did you use ml5 to generate the saved model that you are loading?
Yes, it's a ml5 model. I'd love help with it, i'll try playing with the nesting in the meta objects too, see if it works, but if you can do anything to help me figure it out faster, it'd be great! :)
On Sun, Jul 2, 2023 at 7:39 PM Linda Paiste @.***> wrote:
Okay we are getting somewhere! You’ve confirmed that meta.inputs and meta.outputs are both undefined and that’s what triggers the TypeError.
In looking at your meta object I can see that the info which we need is there but it’s not in the right place. It looks like it’s meta.meta.inputs instead of meta.inputs.
I haven’t got to the root problem yet. That is, why the meta is structured incorrectly. I’ll need to play around more and run your code. It’s either a problem with reading your metadata.json file or it’s a problem with exporting the model which led to an incorrect metadata.json. There probably exists a quick fix where I tell you what to change in the metadata.json file to make it work but that’s a poor solution that doesn’t address why it’s wrong. Did you use ml5 to generate the saved model that you are loading?
— Reply to this email directly, view it on GitHub https://github.com/ml5js/ml5-library/issues/1468#issuecomment-1616726247, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5N5RIHOYE6BB6VKG7R63PDXOGP55ANCNFSM6AAAAAAZMNBREU . You are receiving this because you authored the thread.Message ID: @.***>
-- יהונתן יוספי
I took an old minified model someone used and it seems to work now. It seems new updates to ml5 library changed how it works and now legacy code is breaking when updating to it. I don't know at what version the minified library I found works, but it seems to be working fine now.
If there is a way for me to find the new syntaxes for using it in the posenet custom model, I'd love to use that.
On Sun, Jul 2, 2023 at 8:23 PM Yehonatan Yosefi @.***> wrote:
Yes, it's a ml5 model. I'd love help with it, i'll try playing with the nesting in the meta objects too, see if it works, but if you can do anything to help me figure it out faster, it'd be great! :)
On Sun, Jul 2, 2023 at 7:39 PM Linda Paiste @.***> wrote:
Okay we are getting somewhere! You’ve confirmed that meta.inputs and meta.outputs are both undefined and that’s what triggers the TypeError.
In looking at your meta object I can see that the info which we need is there but it’s not in the right place. It looks like it’s meta.meta.inputs instead of meta.inputs.
I haven’t got to the root problem yet. That is, why the meta is structured incorrectly. I’ll need to play around more and run your code. It’s either a problem with reading your metadata.json file or it’s a problem with exporting the model which led to an incorrect metadata.json. There probably exists a quick fix where I tell you what to change in the metadata.json file to make it work but that’s a poor solution that doesn’t address why it’s wrong. Did you use ml5 to generate the saved model that you are loading?
— Reply to this email directly, view it on GitHub https://github.com/ml5js/ml5-library/issues/1468#issuecomment-1616726247, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5N5RIHOYE6BB6VKG7R63PDXOGP55ANCNFSM6AAAAAAZMNBREU . You are receiving this because you authored the thread.Message ID: @.***>
-- יהונתן יוספי
-- יהונתן יוספי
Hey there! I'm trying to use ml5js in a react poseNet project i'm doing and even though i use the same inputs as in a similar yoga project i get this error when doing: 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) } brainRef.current.classify(inputs, gotResults) it somehow doesn't recognize the right inputs in the latest ml5js library and the results on gotResults are undefined.
error: TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>) at t.<anonymous> (index.js:1044:1) at l (runtime.js:63:1) at Generator._invoke (runtime.js:294:1) at http://Generator.next (runtime.js:119:1) at n (asyncToGenerator.js:3:1) at s (asyncToGenerator.js:25:1) at asyncToGenerator.js:32:1 at new Promise (<anonymous>) at t.<anonymous> (asyncToGenerator.js:21:1)
it says the error is in classifyInternal on the npm package (i'm using latest one). would you please be able to help?