P5 sketch

https://editor.p5js.org/JiawenW/sketches/y_foq8G5F

In this sketch, I want to train my own gesture sign. I have for direction: up, down, left, right, similar to the game I made last week. for better UI and interaction purpose I add a countdown function after the user click each button to get ready, I also add status message to guide the user. I made a Timer that automatically collects a set number of hand pose samples (I set the sample size to 10) for the chosen gesture class, updating the UI as it goes.

Screenshot 2025-10-21 at 12.30.33 AM (2) Medium.jpeg

Screenshot 2025-10-21 at 12.35.20 AM (2).png

Originally I want to have a show result button that let the user to test if the model got trained as they want so they can adjust the sample size, but I keep getting errors. I think this might be the p5 browser error? since I check the data set that’s been saved and everything looks normal.

This is my code for returning result:

if (isPredicting && isTrained && hands.length) { let input = hands[0].keypoints.flatMap((kp) => [kp.x, kp.y]); nn.classify(input, (err, results) => { if (err) { statusMsg = "Classification error!"; classification = null; return; }

Since the hand post model got train, and the data set is good (have hands.length), I don’t know what can I do more to debug. I tried to import the json model file that I saved to see if there’s issue with my model set, but P5 don’t let me import the json, so I manually add the json data in a new json file. Then I realize that I need to re-run the sketch and that would break my condition of show result function. So in the future I want to dive deeper and debug this.

//use Claude code to debug