Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
-
from diffusers import
|
4 |
-
from PIL import Image
|
5 |
-
import imageio
|
6 |
|
7 |
-
model_id = "
|
8 |
-
|
9 |
-
pipe = AnimateDiffPipeline.from_pretrained(
|
10 |
-
model_id,
|
11 |
-
torch_dtype=torch.float16,
|
12 |
-
variant="fp16",
|
13 |
-
use_auth_token=True
|
14 |
-
)
|
15 |
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
16 |
|
17 |
-
def
|
18 |
-
|
19 |
-
|
20 |
output_path = "output.mp4"
|
21 |
-
|
|
|
|
|
22 |
return output_path
|
23 |
|
24 |
gr.Interface(
|
25 |
-
fn=
|
26 |
-
inputs=
|
27 |
-
gr.Image(type="pil", label="ارفع صورة (512x512)"),
|
28 |
-
gr.Textbox(label="أدخل وصف الفيديو (اختياري)")
|
29 |
-
],
|
30 |
outputs=gr.Video(label="الفيديو الناتج"),
|
31 |
-
title="تحويل
|
32 |
-
).launch()
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
+
from diffusers import DiffusionPipeline
|
|
|
|
|
4 |
|
5 |
+
model_id = "cerspense/zeroscope_v2_576w"
|
6 |
+
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
|
9 |
+
def text_to_video(prompt):
|
10 |
+
output = pipe(prompt, num_inference_steps=25)
|
11 |
+
video_frames = output.frames[0]
|
12 |
output_path = "output.mp4"
|
13 |
+
|
14 |
+
import imageio
|
15 |
+
imageio.mimsave(output_path, video_frames, fps=8)
|
16 |
return output_path
|
17 |
|
18 |
gr.Interface(
|
19 |
+
fn=text_to_video,
|
20 |
+
inputs=gr.Textbox(label="أدخل وصف الفيديو (بالإنجليزية)"),
|
|
|
|
|
|
|
21 |
outputs=gr.Video(label="الفيديو الناتج"),
|
22 |
+
title="تحويل نص إلى فيديو باستخدام ZeroScope"
|
23 |
+
).launch()
|