Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718192021222324import gradio as grdef dummy_video_process(video):# For now, just return the same videoreturn videowith gr.Blocks() as demo:gr.Markdown("# RustyVideo ๐ฅ")gr.Markdown("Upload a video and RustyAI will (soon) do something crazy with 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")run_btn.click(fn=dummy_video_process,inputs=input_video,outputs=output_video)if __name__ == "__main__":demo.launch()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import gradio as grfrom huggingface_hub import InferenceClientfrom PIL import Imageimport os# Connecting to the ultimate image-to-video processing backendclient = InferenceClient()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 formatimg = Image.fromarray(input_image)# If you leave the text box blank, it defaults to a clean, smooth animation sequencefinal_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 modelvideo_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_filenameexcept 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():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=animate_uploaded_image,inputs=[user_image, user_prompt],outputs=video_output)if __name__ == "__main__":demo.launch()
app.py+51-15