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.
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?
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.
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.
@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.
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:
import os
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.