Giter Club home page Giter Club logo

ml-classifier's Issues

Error while training model

I was trying your tutorial from here:https://thekevinscott.com/image-classification-with-javascript/

Everything works fine until I call model.fit(). Below is the exception I get.
Error: Error when checking input: expected flatten_Flatten1_input to have shape [,7,7,256], but got array with shape [2,224,224,3]

If I change this line: tf.layers.flatten({inputShape: [7, 7, 256]}) to tf.layers.flatten({inputShape: [224, 224, 3]}), the browser crashes. Can you tell me what I'm doing wrong ?

Error loading the model

Trying to reproduce the README example:

    const loadImage = (src) => new Promise((resolve, reject) => {
      const image = new Image();
      image.src = src;
      image.crossOrigin = 'Anonymous';
      image.onload = () => resolve(image);
      image.onerror = (err) => reject(err);
    });

    const pretrainedModelURL = 'https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json';

    tf.loadModel(pretrainedModelURL).then(model => {
      const layer = model.getLayer('conv_pw_13_relu');
      return tf.model({
        inputs: [model.inputs[0]],
        outputs: layer.output,
      });
    }).then(pretrainedModel => {
      return tf.loadModel('/model.json').then(model => {
        return loadImage('/trees/tree1.png').then(loadedImage => {
          const image = tf.reshape(tf.fromPixels(loadedImage), [1,224,224,3]);
          const pretrainedModelPrediction = pretrainedModel.predict(image);
          const modelPrediction = model.predict(pretrainedModelPrediction);
          const prediction = modelPrediction.as1D().argMax().dataSync()[0];
          console.log(prediction);
        });
      });
    }).catch(err => {
      console.error('Error', err);
    });

I have an error from the line:

const pretrainedModelPrediction = pretrainedModel.predict(image);

The error is the next one:

tfjs.js:67 Uncaught (in promise) Error: The dtype of the feed (int32) is incompatible with that of the key 'input_1' (float32).
    at new t (tfjs.js:67)
    at assertFeedCompatibility (tfjs.js:67)
    at e.add (tfjs.js:67)
    at new e (tfjs.js:67)
    at tfjs.js:67
    at tfjs.js:49
    at e.scopedRun (tfjs.js:49)
    at e.tidy (tfjs.js:49)
    at e.tidy (tfjs.js:49)
    at s (tfjs.js:67)

Any idea about this error? My tfjs version is 0.12.2.

Hey! how to use the download model?

I think the things you do are great and useful. For convenience, I want to use the model downloaded directly from your web demo. How do I add it to my script in html?

I just do this , it don't work.

function loadMobilenet() {
return tf.loadModel('./model.json');
}

Thank you!

Error while loading model

Getting a Cannot read property 'sourceLayer' of undefined while trying to load pre-trained model (both 'mobilenet_v1_0.25_224' and 'mobilenet_v1_1.0_224'.

Tried with both tf-js v0.12.2 and latest v0.15.3

Upgrade tfjs dependency

Tensorflow.js is at 0.15.3 with a number of functions renamed in anticipation of a 1.0 release. This library should be updated to use the latest tfjs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.