Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline
|
3 |
+
import torch
|
4 |
+
from PIL import Image
|
5 |
+
from moviepy.editor import ImageSequenceClip
|
6 |
+
|
7 |
+
# Загружаем модель
|
8 |
+
pipe = DiffusionPipeline.from_pretrained(
|
9 |
+
"Suparious/FP-image-to-video-FLUX.1-HV-bf16",
|
10 |
+
torch_dtype=torch.bfloat16,
|
11 |
+
variant="bf16"
|
12 |
+
).to("cuda")
|
13 |
+
|
14 |
+
pipe.enable_model_cpu_offload()
|
15 |
+
|
16 |
+
def animate_image(image: Image.Image):
|
17 |
+
result = pipe(image, decode_chunk_size=8)
|
18 |
+
frames = result.frames
|
19 |
+
|
20 |
+
clip = ImageSequenceClip(frames, fps=8)
|
21 |
+
output_path = "output.mp4"
|
22 |
+
clip.write_videofile(output_path, codec="libx264", audio=False)
|
23 |
+
|
24 |
+
return output_path
|
25 |
+
|
26 |
+
demo = gr.Interface(
|
27 |
+
fn=animate_image,
|
28 |
+
inputs=gr.Image(type="pil"),
|
29 |
+
outputs=gr.Video(),
|
30 |
+
title="🌀 FP Image to Video Animation",
|
31 |
+
description="Загрузи изображение, и модель FLUX.1 превратит его в короткое анимированное видео."
|
32 |
+
)
|
33 |
+
|
34 |
+
demo.launch()
|