Spaces:
Sleeping
Sleeping
Update app.py
Browse files123453456787899101112131415161718192021222324252627282930313233343536373839404142121314151643444546474849505152531819205455565758592460import gradio as grfrom huggingface_hub import InferenceClientfrom PIL import Imageimport os
def dummy_video_process(video): # For now, just return the same video return video# Connecting to the ultimate image-to-video processing backendclient = InferenceClient()
with gr.Blocks() as demo: gr.Markdown("# RustyVideo ๐ฅ") gr.Markdown("Upload a video and RustyAI will (soon) do something crazy with it.")def animate_uploaded_image(input_image, motion_prompt): if input_image is None: return None # Convert the user's uploaded picture into the correct pixel format img = Image.fromarray(input_image) # If you leave the text box blank, it defaults to a clean, smooth animation sequence final_prompt = motion_prompt if motion_prompt else "smooth animation, high quality, realistic motion" print(f"RustyAI Engine is animating your image with motion: {final_prompt}") try: # Passes your actual file directly to the external animation model video_bytes = client.image_to_video( image=img, prompt=final_prompt, model="Lightricks/LTX-Video" ) output_filename = "rusty_animated_output.mp4" with open(output_filename, "wb") as f: f.write(video_bytes) return output_filename except Exception as e: print(f"Animation Error: {e}") return None
# Setting up the exact Image-to-Animation interface for RustyAIwith gr.Blocks(title="RustyAI Image Animator") as demo: gr.Markdown("# ๐ฌ RustyAI Image-to-Animation Machine") gr.Markdown("Upload a static image, type how it should move, and watch your AI animate it!") with gr.Row(): input_video = gr.Video(label="Input video") output_video = gr.Video(label="Output video")
run_btn = gr.Button("Process with RustyAI")
with gr.Column(): user_image = gr.Image(label="1. Drag or Upload your photo here") user_prompt = gr.Textbox( label="2. Motion Prompt (Optional)", placeholder="e.g., the character walks forward, camera shakes, eyes blink..." ) run_btn = gr.Button("Animate My Image ๐", variant="primary") with gr.Column(): video_output = gr.Video(label="Your Animated Result") run_btn.click( fn=dummy_video_process, inputs=input_video, outputs=output_video fn=animate_uploaded_image, inputs=[user_image, user_prompt], outputs=video_output )
if __name__ == "__main__": demo.launch() demo.launch()app.py+51-15