I trained an image classification neural network model written in ml5.js. When I try to use the model files in a p5.js web editor, I get an error 'Based on the provided shape, [1,64,64,4], the tensor should have 16384 values but has 20155392'.
The code is in this p5 sketch - https://editor.p5js.org/konstantina1/sketches/85Ny1SC2J (clicking on the arrow in the top right corner will show the files).
When I run a local server on a web page with the same structure, I see 'model ready!' (a confirmation that the model has loaded) and that's it.
I read a lot of comments that the bin file may be corrupt - I saved the model myself producing the bin file so it should be ok.
As suggested here by the author of very similar code, https://www.youtube.com/watch?v=3MqJzMvHE3E, adding pixelDensity(1) in setup() doesn't help.
I am new to machine learning, could someone please help? Thank you in advance.
Failure to use ml5.js image classification model-Error: Based on the provided shape, [1,64,64,4], the tensor should have 16384 values but has 20155392
529 views Asked by Konstantina At
2
There are 2 answers
0
Konstantina
On
A version of the sketch with image file upload: https://editor.p5js.org/konstantina1/sketches/qMNkkkbIm
Related Questions in CONV-NEURAL-NETWORK
- The meaning of an out_channel in nn.Conv2d pytorch
- Difference between model.evaluate and metrics.accuracy_score
- PyTorch training on M2 GPU slower than Colab CPU
- LeNet5 & Self-Organizing Maps - RuntimeError: Trying to backward through the graph a second time - PyTorch
- How I resolve : InvalidArgumentError: Graph execution error?
- Ensemble Learning
- Implementing tflite quantized inference in python
- how to set a custom prior for Convolution2DReparameterization?
- this code is not working on tensorflow 2.16.0+ version
- How to cut out a fragment of an image in a contour
- Can I treat CNN channels separately to make placement predictions?
- Image channel error while training CNN model
- What is the size difference between Convolutional Neural Networks that take as input an RGB vs. monochrome image?
- Struggling to put my input images in the right format for CNN (tensorflow)
- Siamese Network Backpropagation
Related Questions in P5.JS
- Performance of sketch drastically decreases outside of the P5 Web Editor
- The p5js library's loadFont function does not seem to work for me?
- Why is toDataURL() returning blank image? (with p5 video)
- how to stretch the video feed from camera on p5.js
- "Invalid JSON response: null" error when using Gemini Pro Vision AI API in Node.js
- Why does the shadow appear above the image in this p5.js code?
- Is it possible to unpack/destructure class attributes into variables?
- How to make the ball act more realisticly in my pong game?
- p5.js rotate unexpected results
- P5.js button that displays a 3D model when touched
- How to extend p5.js's TypeScript definition?
- Does p5.js support steering wheel and gas pedal input and how to read input?
- How can I optimize this specific part of my p5js code (using trig functions) to reduce lag while maintaining the visual effect?
- Rendering p5.js sketch on my Jekyll website
- Add p5js to the typescript and webpack template app created in electron forge
Related Questions in TENSORFLOW.JS
- Error trying to predict in TensorFlow.js and react
- How can I import "@tensorflow/tfjs" module in javascript.?
- How to merge LoRA weights to an LLM at initialization time on-device (Gemma)
- How can I package tensorflow/tfjs-node in an electron app using electron-forge?
- Tensorflow.js Error: Backend name ‘webgpu’ not found in registry when not served on localhost
- Expo react-native apk build failure on EAS
- tfjs: Adam learning rate decay
- How to Integrate custom tf model in react native mobile app
- TF JS crash in engine.ts
- tfjs-node training vs tfjs browser predictions giving NaN
- How to Implement a tenserflow models prediction in a react native app page
- How to slice 4d tensor in tensorflow.js?
- How to access different feature maps created by conv2d layers in tensorflowjs?
- Training the tenserflow js model with a large amount of data
- tf.unsortedSegmentSum does not aggregate all indices?
Related Questions in IMAGE-CLASSIFICATION
- Error while loading .keras model: Layer node index out of bounds
- While working on binary image classification, the class mode set to binary incorrectly labels the images, but does it correct on categorical
- Segmentation with Geotiff image
- Simple ResNet model can not tell if two monotone images are the same color
- Given groups=1, weight of size [16, 32, 3, 3], expected input[42, 19, 224, 224] to have 32 channels, but got 19 channels instead
- Template matching model for object orientation estimation converges fast with in-plane rotations only, but fails with full 3D orientations
- K means loop doesn't work for the image clustering
- Issue with HuggingFace Inference API for ViT Model - “image-feature-extraction” Error
- How to solve this error "UnsupportedOperation: fileno"
- Tensor size mismatch while running SHAP DeepExplainer
- Ways to convert 4x4 grid of icons to Text
- Designing Loss Function for Multi-Label Classification Problem with Fixed Number of Labels
- building custom image classification model not working
- Medical Binary Classification probability : BCE vs CrossEntropy
- How do i change the input shape of a pytorch resnet50 model before training to 224, 224, 3 from 3, 224, 224
Related Questions in ML5.JS
- Problem in trying to run a digit classifier in a webapp that captures image in a drawing pad
- Teachable Machine and p5.js
- I am using p5.js and ml5.js. How do I set the background of a canvas to the camera?
- How to fix p5js Ml5 BodyPix "TypeError: Right-hand side of instanceof is not an object" error, following Dan shiffman Tutorial
- ml5.js tf.js featureExtractor addImage memory leak WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost
- ml5.js error when creating a neural network
- ML5.js wrong predict for a basic linear regression
- How to stop sound classification in ml5.js
- working on the coding train's cocossd tutorial, I cannot seem to find a way to get the squares around the detected things
- Uncaught (in promise) TypeError: e is not a function
- import a local model trained
- Uncaught (in promise) Error: Error: Error in oneHot: depth must be >=2, but it is 1
- Use audio stream as an audio input in ml5.js
- p5.js eye tracking using ml5 library
- Failure to use ml5.js image classification model-Error: Based on the provided shape, [1,64,64,4], the tensor should have 16384 values but has 20155392
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The model was trained with images 64x64 px so the input test image must be the same size.
1944 (original image width) * 2592 (original image height) * 4 (number of channels) = 20155392. The tensor should have 64 (image width) * 64 (image height) * 4 (number of channels) = 16387 values. This is what the error refers to.
The
copy()method used originally didn't resize the input image properly. The correct way to resize the image isinputImage.resize(IMAGE_WIDTH, IMAGE_HEIGHT).Working sketch: https://editor.p5js.org/konstantina1/sketches/85Ny1SC2J