Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import torch | |
| from diffusers import StableVideoDiffusionPipeline | |
| from diffusers.utils import export_to_video | |
| # CPU için yapılandırıldı | |
| pipe = StableVideoDiffusionPipeline.from_pretrained( | |
| "stabilityai/stable-video-diffusion-img2vid-xt", | |
| torch_dtype=torch.float32 # CPU'da float32 zorunludur | |
| ) | |
| pipe.to("cpu") | |
| def generate_video(image): | |
| image = image.resize((512, 320)) # CPU'da çok büyük görsel hata verir | |
| frames = pipe(image, decode_chunk_size=2, motion_bucket_id=127).frames[0] | |
| export_to_video(frames, "output.mp4", fps=7) | |
| return "output.mp4" | |
| demo = gr.Interface(fn=generate_video, inputs=gr.Image(type="pil"), outputs=gr.Video()) | |
| demo.launch() |