Hi iam trying to access a hugging face space into other space
my app.py
import os
import gradio as gr
from huggingface_hub import HfApi
from gradio_client.exceptions import AuthenticationError
def load_space():
# Try to get the token from environment variable
hf_token = os.environ.get('api')
if not hf_token:
print("Warning: HUGGINGFACE_TOKEN environment variable not set.")
print("Attempting to use Hugging Face CLI login...")
try:
# Attempt to load the space
iface = gr.load(
name="My space",
hf_token=hf_token,
src="spaces"
)
print("Space loaded successfully!")
return iface
except AuthenticationError as e:
print(f"Authentication error: {e}")
print("Please make sure you're logged in or using a valid token.")
return None
except Exception as e:
print(f"An error occurred: {e}")
return None
def main():
iface = load_space()
if iface:
iface.queue(max_size=300)
iface.launch(debug=False)
else:
print("Failed to load the space. Please check the error messages above.")
if __name__ == "__main__":
main()
My output
runtime error
ZeroGPU has not been initialized
Container logs:
===== Application Startup at 2024-08-29 21:20:08 =====
Fetching Space from: https://huggingface.co/spaces/....
Loaded as API: https://---.hf.space ✔
Space loaded successfully!
Running on local URL: http://0.0.0.0:7860
To create a public link, set `share=True` in `launch()`.