Edee
Edee

Reputation: 1836

Javascript cdn resource fail

I follow the instruction, but error report like this

enter image description here

my code:

<html>
  <head>
    <!-- Load TensorFlow.js -->
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs"></script>
    <!-- Load Posenet -->
    <script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/posenet"></script>
 </head>

  <body>
    <img id='cat' src='./pose/images/aa_090.jpg'/>
  </body>
  <!-- Place your code in the script tag below. You can also use an external .js file -->
  <script>
    var flipHorizontal = false;

    var imageElement = document.getElementById('cat');

    posenet.load().then(function(net) {
      const pose = net.estimateSinglePose(imageElement, {
        flipHorizontal: true
      });
      return pose;
    }).then(function(pose){
      console.log(pose);
    })
  </script>

which is exactly the same as https://github.com/tensorflow/tfjs-models/tree/master/posenet

Plz do me a favor

Upvotes: 0

Views: 72

Answers (1)

400_bad_request
400_bad_request

Reputation: 121

I tried the same code snippet and it worked for me without any issue, the cdn also seems to be working when I checked, so the problem could be a few things:

  1. Your image does not exist at the given location
  2. There was some network issue when you attempted this
  3. There is an issue fetching the image locally due to cors : https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSRequestNotHttp

Incase the issue persists try downloading the CDN's and the image and host it by following,

  1. In the directory of your files run: python -m SimpleHTTPServer 8000
  2. Go to localhost:8000/yourfile.html

Revert back in case of any issues

Upvotes: 1

Related Questions