Image Prediction with Tensorflow JS on simple REACT App | Google's Teachable Machine

Поділитися
Вставка
  • Опубліковано 21 сер 2024
  • Image Prediction with Tensorflow JS on simple REACT App | Google's Teachable Machine
    machine-learning tutorial, machine learning basics, teachable machine tutorial, teachable machine google, teachable machine tutorial 1, teachable machine tutorial 2, teachable machine tutorial 3, image prediction machine learning, describe image prediction 2021
    The project can be found in my GitHub: github.com/dev...
    +++++ IMAGE FROM LOCAL STORAGE +++++++
    If you are looking to try an image from your local system instead of an image URL, you can clone the branch " img-from-local-storage" and it will simple example App with EJS and Node JS
    git clone --branch img-from-local-storage github.com/dev... and follow README to execute the application.
    Thanks for watching, sharing your feedback, and requesting to subscribe to my channel if you haven't done yet as this really keeps motivating me to continue. Thanks!

КОМЕНТАРІ • 9

  • @akshhay
    @akshhay 3 роки тому +4

    Thank you sir, this was what i was searching exactly for

  • @hafizhzulian_
    @hafizhzulian_ Рік тому

    how to predict image that we upload, can you help me ?

  • @farouktouil5036
    @farouktouil5036 3 роки тому +1

    put the app on github please

    • @somnathpaul2020
      @somnathpaul2020  3 роки тому

      I know its quite a bit late, but here you go: github.com/developedbysom/Techablemachine.git

    • @AarushKulkarni
      @AarushKulkarni 3 роки тому

      @@somnathpaul2020 The github does not have the actual code

    • @somnathpaul2020
      @somnathpaul2020  3 роки тому

      @@AarushKulkarni You need to clone the application from master brunch. , please use the following command to clone this app: git clone github.com/developedbysom/Techablemachine.git --branch master.

    • @AarushKulkarni
      @AarushKulkarni 3 роки тому

      @@somnathpaul2020 Thanks

  • @gigachad3861
    @gigachad3861 Рік тому

    bro I have created a model with teachable machine and I'm using Tensorflow js to get predictions it works but its really slow because of model.predict.dataSycn() function takes time to return predictions .
    my code is as follows -:
    //
    const handleCameraStream = (imageAsTensors) => {
    try {
    } catch (e) {
    // console.log("Tensor 1 not found!");
    }
    const loop = async () => {
    // && detected == true
    if (model !== null) {
    if (frameCount % makePredictionsEveryNFrames === 0) {
    const imageTensor = imageAsTensors.next().value;
    await getPrediction(imageTensor);
    // .catch(e => console.log(e));
    }
    }
    frameCount += 1;
    frameCount = frameCount % makePredictionsEveryNFrames;
    requestAnimationFrameId = requestAnimationFrame(loop);
    };
    loop();
    //loop infinitely to constantly make predictions
    };
    //
    const getPrediction = async (tensor) => {
    // if (!videoLink) {
    if (!tensor) {
    console.log("Tensor not found!");
    return;
    }
    //
    const imageData2 = tensor.resizeBilinear([224, 224]);
    // tf.image.resizeBilinear(tensor, [224, 224]);
    const normalized = imageData2.cast("float32").div(127.5).sub(1);
    const final = tf.expandDims(normalized, 0);
    //
    console.time();
    const prediction = model.predict(final).dataSync();
    console.timeEnd();
    console.log("Predictions:", prediction);
    }
    Please help brother my camera is physically lagging when I use the following . I calculated the time it takes to get results from the model.predict.dataSync() function it takes approx. 500ms to get predictions from it . I want this entire process to be instant so that my camera doesn't lag . pls help bro its urgent