Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive CORS issue happening because hub is returning 404 when fetching the model #924

Open
ghaschel opened this issue Jan 20, 2025 · 0 comments

Comments

@ghaschel
Copy link

What happened?

Suddenly I'm getting false positive CORS errors when starting face detection.

Access to fetch at 'https://www.kaggle.com/models/mediapipe/face-landmarks-detection/tfJs/attention-mesh/1/model.json?tfjs-format=file&tfhub-redirect=true' (redirected from 'https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1/model.json?tfjs-format=file') from origin 'http://localhost:5173' 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.

If I try to access the hub link directly (https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1/model.json?tfjs-format=file), it redirects me to (https://www.kaggle.com/models/mediapipe/face-landmarks-detection/tfJs/attention-mesh/1/model.json?tfjs-format=file&tfhub-redirect=true), which returns me 404

Relevant code

await tf.setBackend('webgl')
const model = faceLandmarksDetection.SupportedModels.MediaPipeFaceMesh
const detector = await faceLandmarksDetection.createDetector(model, {
    runtime: 'tfjs',
    refineLandmarks: true,
    maxFaces: 1,
})

Relevant log output

Access to fetch at 'https://www.kaggle.com/models/mediapipe/face-landmarks-detection/tfJs/attention-mesh/1/model.json?tfjs-format=file&tfhub-redirect=true' (redirected from 'https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1/model.json?tfjs-format=file') from origin 'http://localhost:5173' 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.Understand this errorAI
www.kaggle.com/models/mediapipe/face-landmarks-detection/tfJs/attention-mesh/1/model.json?tfjs-format=file&tfhub-redirect=true:1 
        
        
       Failed to load resource: net::ERR_FAILED

tensorflow_hub Version

0.13.0.dev (unstable development build)

TensorFlow Version

2.8 (latest stable release)

Other libraries

    "@mediapipe/face_mesh": "^0.4.1633559619",
    "@tensorflow-models/face-landmarks-detection": "^1.0.6",
    "@tensorflow-models/handpose": "^0.1.0",
    "@tensorflow/tfjs": "^4.22.0",
    "@tensorflow/tfjs-converter": "^4.22.0",
    "@tensorflow/tfjs-core": "^4.22.0",

Python Version

3.x

OS

macOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant