0

I'm receiving an error message: "Error: The shape of dict['images'] provided in model.execute(dict) must be [1,3,640,640], but was [1,640,640,3]". Here is the code I'm working with:

<!DOCTYPE html>
<html>
<head>
  <title>Adding Roboflow.js Modeli</title>
  <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@3.15.0/dist/tf.js"></script>
  <script src="https://cdn.roboflow.com/0.2.20/roboflow.js"></script>
</head>
<body>
  <img id="image" src="images (10).jpg">
  
  <script>
    roboflow.auth({ publishable_key: '************************' }); 
    roboflow.load({
      model: '****', 
      version: '**', 
    }).then(model => {
      model.detect(t4d).then(predictions => {
        console.log(predictions);

        predictions.forEach(prediction => {
          const { class: className, bbox } = prediction;
          const { left, top, width, height } = bbox;
          const div = document.createElement('div');
          div.innerHTML = className;
          div.style.border = '2px solid red';
          div.style.position = 'absolute';
          div.style.left = `${left}px`;
          div.style.top = `${top}px`;
          div.style.width = `${width}px`;
          div.style.height = `${height}px`;
          document.body.appendChild(div);
        });
      }).catch(error => {
        console.error(error);
      });
    }).catch(error => {
      console.error(error);
    });
  </script>
</body>
</html>
alibali
  • 9
  • 1

1 Answers1

0

This Roboflow cdn is deprecated, use instead:

<script src="https://cdn.roboflow.com/0.2.26/roboflow.js"></script>