question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[tfjs-converter] @tensorflow/tfjs 1.2.3 fails to load weights from the official GCP bucket due to CORS issues

See original GitHub issue

TensorFlow.js version

1.2.3 & 1.2.2

Browser version

Chrome Version 77.0.3854.3 (Official Build) dev (64-bit) FireFox 69.0b4 (64-bit)

Bug report

Here is a minimalistic repo showing the bug.

Loading one of the PoseNet weights in the erroring demo fails with:

Access to fetch at 'https://storage.googleapis.com/tfjs-models/savedmodel/posenet/mobilenet/quant2/100/group1-shard2of2.bin' from origin 'http://localhost:1234' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Both Chrome and FireFox allow the JSON file, but deny the loading of the model chunks. Using CORS Everywhere helps in FireFox.

This issue was first spotted in the context of semantic segmentation and text detection models loading weights from a non-official GCP bucket with the following CORS rules suggested by @nsthorat here:

[
 {
   "origin": ["*"],
   "responseHeader": ["Content-Type"],
   "method": ["GET", "HEAD"],
   "maxAgeSeconds": 3600
 }
]

I have tried imposing other rules as well, as described here, but the issue persists.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nsthoratcommented, Jul 18, 2019

Loading from the official buckets should work now. I’m reverting a change that will fix this for any custom server.

0reactions
kangyizhangcommented, Jul 18, 2019

hi @sdll @erikcartman

This is a bug in tfjs@1.2.3 and we will fix it soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - TensorFlowJs & Google Storage | CORS Error with ...
In this specific case, you can configure the Google Cloud Storage bucket to allow resource requests between the bucket containing your ...
Read more >
Google Cloud Storage Cors not working after enabling?
If you experience that the Google Cloud Cors is not working even after you did “gsutil cors set cors.json gs://your-bucket/”, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found