Spaces:
Sleeping
Sleeping
Update app.py
Browse files123445677891011111213141516171415161718192021222324252021222324252826272831323334293031323334353639403738394240414442434644454647import gradio as grfrom huggingface_hub import InferenceClient
# Initialize the inference client for direct text-to-video generation# Connecting to the ultra-fast FLUX image clusterclient = InferenceClient()
def generate_video_from_text(prompt):def generate_studio_art(prompt): if not prompt: return None print(f"RustyAI Engine is manufacturing video for: {prompt}") print(f"RustyAI Engine is rendering art for: {prompt}") try: # Call the external GPU cluster to build a video from text words video_bytes = client.text_to_video( prompt, model="Lightricks/LTX-Video" # Call the server to instantly bake a high-fidelity image file image = client.text_to_image( prompt=prompt, model="black-forest-labs/FLUX.1-schnell" ) output_path = "rusty_text_motion.mp4" with open(output_path, "wb") as f: f.write(video_bytes) print("RustyAI Engine: Text-to-Video generation complete!") return output_path # Save the crisp image file to display output_filename = "rusty_studio_art.png" image.save(output_filename) return output_filename except Exception as e: print(f"Text-to-Video Error: {e}") print(f"Studio Error: {e}") return None
# Clean, simple UI layout for prompt typingwith gr.Blocks(title="RustyAI Text-to-Video") as demo: gr.Markdown("# 🎬 RustyAI Text-to-Video Generator") gr.Markdown("Type a scene description below and watch the AI manifest it into a video clip.")# Custom UI layout for your RustyAI Image Studiowith gr.Blocks(title="RustyAI Image Studio") as demo: gr.Markdown("# 🎨 RustyAI Image Studio") gr.Markdown("Type an idea, hit generate, and watch the FLUX engine bake high-speed concept art!") with gr.Row(): with gr.Column(): user_prompt = gr.Textbox( label="Describe your video scene", placeholder="e.g., A multi-armed wooden creature swinging baseball bats in a dark room, analog horror style..." label="Describe your artwork or character design", placeholder="e.g., A terrifying analog horror entity with glowing eyes standing in a dark basement, VHS tape overlay, highly detailed 3D render..." ) run_btn = gr.Button("Bake Video 🚀", variant="primary") run_btn = gr.Button("Generate Art ✨", variant="primary") with gr.Column(): video_output = gr.Video(label="Generated MP4 Output") image_output = gr.Image(label="Rendered Result") run_btn.click(fn=generate_video_from_text, inputs=user_prompt, outputs=video_output) run_btn.click(fn=generate_studio_art, inputs=user_prompt, outputs=image_output)
if __name__ == "__main__": demo.launch()app.py+21-23