tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.47k stars 1.66k forks source link

Bug: sudden 403 for certain models #889

Closed johnsonps08 closed 1 year ago

johnsonps08 commented 1 year ago

What happened?

Attempting to get following models:

but getting 403 and CORS errors on GET.

Relevant code - tested in Postman

curl --location 'https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1/model.json?tfjs-format=file' \
--header 'authority: tfhub.dev' \
--header 'accept: */*' \
--header 'accept-language: en-US,en;q=0.9' \
--header 'cache-control: no-cache' \
--header 'origin: http://localhost:4200' \
--header 'pragma: no-cache' \
--header 'referer: http://localhost:4200/' \
--header 'sec-ch-ua: "Not.A/Brand";v="8", "Chromium";v="114", "Brave";v="114"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "macOS"' \
--header 'sec-fetch-dest: empty' \
--header 'sec-fetch-mode: cors' \
--header 'sec-gpc: 1' \
--header 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36'

Relevant log output

<h1>Forbidden</h1>
<h2>Error 403</h2>

tensorflow_hub Version

0.12.0 (latest stable release)

TensorFlow Version

2.8 (latest stable release)

Other libraries

calls are going through these libraries: "@tensorflow-models/face-landmarks-detection": "0.0.3" "@tensorflow/tfjs": "^3.15.0"

Python Version

3.x

OS

macOS

johnsonps08 commented 1 year ago

Additional info: this was working yesterday in both a local environment and a deployed environment. This isn't my project but you can go to Webgazer.js collision demo, inspect the page, and look at the network tab to see the exact same issue we're experiencing.

Worth mentioning that if I disable the sec-fetch-site header in Postman, the GET request returns as expected. Nothing in our project or site would have updated the request headers between yesterday and today.

akhorlin commented 1 year ago

There was an intermittent issue. Please give it a try.

johnsonps08 commented 1 year ago

@akhorlin thanks so much for the follow up. It is working now in all of our cases, local and deployed. I also noticed is is working on the demo for WebGazer.js.

Can you shed any light on what happened? Is the issue something that we could code more defensively for prevention of outage in the future?

singhniraj08 commented 1 year ago

@johnsonps08,

There was an intermittent issue from our side which is fixed and there is nothing needed to be done from your end. You can refer Common issues in future for intermittent failures. Since this issue is fixed now, requesting you to close this issue. Thank you!

johnsonps08 commented 1 year ago

Hi @singhniraj08 thanks for the update. Nothing in the Common Issues section you referenced seemed to match up with our issue. I'll be glad to mark this issue as closed with one last question: if we get 403 errors in the future, would it be best to open a ticket here right away or is there another, faster way to have that issue resolved?

singhniraj08 commented 1 year ago

@johnsonps08,

We don't expect 403 errors, but since this occurred by some internal issues for which there is nothing needed to be done from your end, please feel free to create a new issue here if similar issue pops up in future. Thank you!

google-ml-butler[bot] commented 1 year ago

Are you satisfied with the resolution of your issue? Yes No

gvgohil232 commented 5 months ago

Hello @singhniraj08 Is there any changes going on in TensorFlow, I am getting a similar issue for fetch failed from 'https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1/model.json?tfjs-format=file') from origin 'http://localhost' has been blocked by CORS policy:

Please let me know how can I resolve this issue as my code is on live and it was working fine and now getting an error for CORS.

HarshJain99 commented 5 months ago

I have also been facing the same issue for the blazeface model since this morning. Is this an intermittent issue or are any code updates expected from our end?

Browser console log

Access to fetch at 'https://www.kaggle.com/models/tensorflow/blazeface/frameworks/tfJs/variations/default/versions/1/model.json?tfjs-format=file&tfhub-redirect=true' (redirected from 'https://tfhub.dev/tensorflow/tfjs-model/blazeface/1/default/1/model.json?tfjs-format=file') from origin xxxxxxxxxxxxxxxxxxxxxxx has been blocked by CORS policy: 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.