Update app.py
Browse files
app.py
CHANGED
|
@@ -3,31 +3,26 @@ import torch
|
|
| 3 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
import uuid
|
| 6 |
-
import
|
| 7 |
|
| 8 |
model_id = "vdo/zeroscope_v2_576w"
|
| 9 |
-
|
| 10 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 11 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 12 |
pipe.to("cpu")
|
| 13 |
|
| 14 |
def generate_video(prompt):
|
| 15 |
try:
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
num_frames=6
|
| 23 |
-
).frames
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
export_to_video(video_frames[0], video_path, fps=8)
|
| 28 |
-
return video_path
|
| 29 |
except Exception as e:
|
| 30 |
-
print(f"
|
| 31 |
return None
|
| 32 |
|
| 33 |
demo = gr.Interface(fn=generate_video, inputs="text", outputs="video", api_name="predict")
|
|
|
|
| 3 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
import uuid
|
| 6 |
+
import os
|
| 7 |
|
| 8 |
model_id = "vdo/zeroscope_v2_576w"
|
|
|
|
| 9 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 10 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 11 |
pipe.to("cpu")
|
| 12 |
|
| 13 |
def generate_video(prompt):
|
| 14 |
try:
|
| 15 |
+
# Hızlı üretim için mevcut ayarlarını koruyorum patron
|
| 16 |
+
frames = pipe(prompt, num_inference_steps=3, height=256, width=256, num_frames=6).frames
|
| 17 |
+
|
| 18 |
+
# Dosyayı "static" bir isme değil, her seferinde farklı bir klasöre yazalım
|
| 19 |
+
unique_name = f"result_{uuid.uuid4()}.mp4"
|
| 20 |
+
export_to_video(frames[0], unique_name, fps=8)
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
# Dosyanın tam yolunu döndür (n8n'in bulması kolaylaşsın)
|
| 23 |
+
return os.path.abspath(unique_name)
|
|
|
|
|
|
|
| 24 |
except Exception as e:
|
| 25 |
+
print(f"HATA: {e}")
|
| 26 |
return None
|
| 27 |
|
| 28 |
demo = gr.Interface(fn=generate_video, inputs="text", outputs="video", api_name="predict")
|