CORs headers for model files
See original GitHub issueIs your feature request related to a problem? Please describe. I’m porting some popular models to work in web browsers (using tfjs/onnx/tflite), and as part of doing this I’d like to host my model somewhere. If the model is small enough, I can just host the model in the Github repo itself, like I’ve done for this version of AnimeGANv2 that runs in the browser:
- https://github.com/josephrocca/anime-gan-v2-web
- https://josephrocca.github.io/anime-gan-v2-web/onnx.html
However, this doesn’t really work if the model is more than a dozen or so megabytes due to the way git/Github is designed. I’ve got a working JS port of OpenAI’s CLIP model that I’d like to share a web demo for, but I need to host the model somewhere. Huggingface seems like a perfect service for this, but I’m running into a problem: Huggingface doesn’t serve model files with the Access-Control-Allow-Origin: *
header, and so the files can’t be downloaded from JavaScript that’s running on another website (such as josephrocca.github.io
).
So, for example, if you run this on a website other than huggingface.co
:
let onnxFile = await fetch("https://huggingface.co/rocca/openai-clip-js/resolve/main/clip-image-vit-32-float32.onnx").then(r => r.blob());
You’ll get an error like this:
Describe the solution you’d like
If the Access-Control-Allow-Origin: *
header could be added to the serving code for model files, that would allow Huggingface to be used for hosting web-based models (onnx, tfjs, tflite).
Describe alternatives you’ve considered I could host the model elsewhere, but I like Huggingface and want to host all my models there 😃
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:10 (6 by maintainers)
Top GitHub Comments
i think this is a reasonable request! cc @SBrandeis @Pierrci what do you think?
Awesome!
Very bare-bones/proof-of-concept demo for OpenAI’s CLIP in the browser, served by HuggingFace🤗:
Thank you @Pierrci, @julien-c, and team 🎉🎉🙏 There are some exciting APIs currently being prototyped by the Chrome team which could bring at lot of maturity to browsers as platforms for deploying ML solutions. HuggingFace is going to be a great resource for the web ML ecosystem as it grows!