I think I must be missing something. Can someone tell me what?
- Embedding spaces is a great option - but only available for public spaces
- The gradio instructions even show how to add authentication - awesome!
- But as your space is now public (because 1), you have to remember to add your auth credentials in a secret, otherwise anyone can just see it in your code
- Also, you have to make your space public to use the Embed option, while you may not have been ready to do so
My take: One of the clear use cases to use “Embed your space” is to share the app without sharing the code (e.g. prototype for something that is in stealth), but by only allowing the option for public spaces, that use case won’t fly.
Am I missing something? Is there a better way to do this?
For anyone else reading this: I couldn’t find a good solution this for my situation, so I ended up running my Gradio application on one of the well known PaaS providers. Works quite well with github integration, just had to set a few environment settings.
I do want to stress that I’m still a huge fan of Huggingface, and it may not make sense for the platform to support the “stealth” scenario I describe above.
Hello @EtheE, thank you for your feedback. We have received similar requests in the past, we might implement a solution it in the future. However, we have previously suggested different workarounds depending on the specific use case:
To hide sensitive source code on Space, you can create a private Space and a second public Space which only loads the private Space using the ‘gr.Interface.load()’ method. This method can load a Space even if it is private. Check more her Gradio Docs.
To hide specific files only, you can create a private dataset/model and use the ‘huggingface_hub’ client to load your dataset/model using the hub token via Space settings.
You can also use our Inference Endpoints PaaS service which is fully integrated with HF tools and our hub. This service provides a way to deploy a Space as a REST API. You can learn more about it here Inference Endpoints - Hugging Face
Thanks @radames! Even though I searched, I hadn’t come across that first answer! While it introduces a bit of overhead, it’s definitely a good option and something I’ll give another try in the near future.
Thanks for the feedback, I’ll update our Space docs
Hello @radames, thank you for the suggestions. I just tried the first option (load Space from a private Space), but the app throws this error if the source code Space is private:
File "/home/user/.local/lib/python3.8/site-packages/websockets/legacy/client.py", line 329, in handshake
raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 404
Maybe something change lately within Spaces?
I´m using Gradio Blocks instead of directly use gr.load(), according to their documentation. Would this cause the problem?
However, using ‘gr.load()’ method need user_token, which will be public in the second space.
hi @germanp, can you please make sure you’re on the latest Gradio version?, checking on the metadata on README.md
you can use the Spaces secrets to share your user_token, that will be on the server side on your Gradio app, Spaces Overview
Thank you for your response! I just tried it and it worked, but the output is empty while the referenced space works well. It takes the same amount of time as the referenced space, so I think it should have actually run, but there was no expected output.
My take: I use ‘gr.load().launch()’, my space’s input is a image and output is a video.
another alternative is to try our new gradio client library, it also supports loading from a private Space
I guess that the video is stored in the referenced space, the output component use the path of the video, when it comes to the second space, it can’t find the video path in his own space, so the output is empty.
I solved my problem perfectly with this solution. Thank you very much
very cool @o0o0o00o0 , cc @freddyaboulton since Gradio client solved the issue
@o0o0o00o0 @radames I tried this the gradio_client solution to call a private HF space of mine, but the API link I got (in the format of xxx-yyy.hf.space) is not sharable and can only be used by me. Is there a way make it sharable to others?
Using the gr.load() method I got into the same issue as @o0o0o00o0, where the output images are empty.
Have you make the space which uses the gradio_client solution public?
Hi there, I get the following error when I try launching a public space.
for fn_index, dependency in enumerate(self.config["dependencies"])
Would you know why this is happening?
Thanks for responding @o0o0o00o0 . I have made it public.
Just in case I misunderstood the instruction, here’s my code for the new HF space, which should take image inputs from users and output images:
from gradio_client import Client
HF_token = os.environ.get('HF_token')
client = Client('xxx/yyy', hf_token=HF_token )
The new space actually resulted in a runtime error:
Loaded as API: https://xxx-yyy.hf.space
and this API above is what I was referring to as not sharable.
Hi there, did you solve this?
I also got this error but don’t know what happened.
I am also getting the same error. Not able to load private space from public space with HF token