Spaces:
Running
Running
| import gradio as gr | |
| from gradio_client import Client | |
| import os | |
| # --- CONFIGURATION --- | |
| TARGET_SPACE = "magnetoid/tencent-HunyuanVideo" | |
| HF_TOKEN = os.getenv("HF_TOKEN") | |
| def generate_video(prompt, duration): | |
| # Connect to the external space | |
| client = Client(TARGET_SPACE) | |
| try: | |
| print(f"Sending request to {TARGET_SPACE}...") | |
| # Call the API | |
| result = client.predict( | |
| prompt=prompt, | |
| video_length=int(duration), | |
| width=1280, | |
| height=720, | |
| infer_steps=30, | |
| fps=24, | |
| api_name="/predict" | |
| ) | |
| # Return the video file path | |
| return result[0] if isinstance(result, (list, tuple)) else result | |
| except Exception as e: | |
| return f"Error: {str(e)}\n\nTip: The host space might be busy. Try changing TARGET_SPACE to 'tencent/HunyuanVideo'." | |
| # --- SIMPLIFIED UI (No Theme) --- | |
| # We removed "theme=..." to fix your error | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# 🕷️ Sora 2 'Parasite' Generator") | |
| gr.Markdown(f"Connected to external GPU host: `{TARGET_SPACE}`") | |
| with gr.Row(): | |
| with gr.Column(): | |
| prompt = gr.Textbox(label="Prompt", placeholder="A cinematic drone shot of a futuristic city...") | |
| duration = gr.Slider(minimum=65, maximum=129, value=85, step=1, label="Frame Length") | |
| btn = gr.Button("Generate", variant="primary") | |
| with gr.Column(): | |
| output_video = gr.Video(label="Result") | |
| btn.click(fn=generate_video, inputs=[prompt, duration], outputs=output_video) | |
| demo.queue().launch() | |