Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,30 +3,31 @@ import torch
|
|
| 3 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
import uuid
|
| 6 |
-
import os
|
| 7 |
|
| 8 |
-
#
|
| 9 |
model_id = "vdo/zeroscope_v2_576w"
|
| 10 |
|
| 11 |
-
|
| 12 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 13 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 14 |
-
|
| 15 |
-
print(f"Model yukleme hatasi: {e}")
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
video_frames = pipe(prompt, num_inference_steps=10, height=320, width=576, num_frames=16).frames
|
| 20 |
video_path = f"video_{uuid.uuid4()}.mp4"
|
| 21 |
export_to_video(video_frames[0], video_path)
|
| 22 |
return video_path
|
| 23 |
|
| 24 |
-
# n8n ile
|
| 25 |
demo = gr.Interface(
|
| 26 |
-
fn=
|
| 27 |
inputs=gr.Textbox(label="Prompt"),
|
| 28 |
outputs=gr.Video(label="Result"),
|
| 29 |
-
api_name="predict"
|
| 30 |
)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
|
|
|
| 3 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
import uuid
|
|
|
|
| 6 |
|
| 7 |
+
# CPU Dostu Model
|
| 8 |
model_id = "vdo/zeroscope_v2_576w"
|
| 9 |
|
| 10 |
+
def load_pipeline():
|
| 11 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 12 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 13 |
+
return pipe
|
|
|
|
| 14 |
|
| 15 |
+
# Pipeline'ı globalde tanımlıyoruz
|
| 16 |
+
pipe = load_pipeline()
|
| 17 |
+
|
| 18 |
+
def generate_video(prompt):
|
| 19 |
+
# CPU için en hafif ayarlar
|
| 20 |
video_frames = pipe(prompt, num_inference_steps=10, height=320, width=576, num_frames=16).frames
|
| 21 |
video_path = f"video_{uuid.uuid4()}.mp4"
|
| 22 |
export_to_video(video_frames[0], video_path)
|
| 23 |
return video_path
|
| 24 |
|
| 25 |
+
# n8n ile %100 uyumlu API ismi
|
| 26 |
demo = gr.Interface(
|
| 27 |
+
fn=generate_video,
|
| 28 |
inputs=gr.Textbox(label="Prompt"),
|
| 29 |
outputs=gr.Video(label="Result"),
|
| 30 |
+
api_name="predict"
|
| 31 |
)
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|