Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,8 @@ import torch
|
|
| 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)
|
|
@@ -12,23 +12,25 @@ pipe.to("cpu")
|
|
| 12 |
|
| 13 |
def generate_video(prompt):
|
| 14 |
try:
|
| 15 |
-
#
|
| 16 |
-
# num_inference_steps
|
| 17 |
-
# num_frames: 24 (Video 3 saniye ve daha akıcı olacak)
|
| 18 |
frames = pipe(
|
| 19 |
prompt,
|
| 20 |
-
num_inference_steps=
|
| 21 |
height=320,
|
| 22 |
width=576,
|
| 23 |
-
num_frames=
|
| 24 |
).frames
|
| 25 |
|
| 26 |
-
|
| 27 |
-
export_to_video(frames[0],
|
| 28 |
-
|
|
|
|
|
|
|
| 29 |
except Exception as e:
|
| 30 |
-
print(f"HATA: {e}")
|
| 31 |
return None
|
| 32 |
|
|
|
|
| 33 |
demo = gr.Interface(fn=generate_video, inputs="text", outputs="video", api_name="predict")
|
| 34 |
demo.launch()
|
|
|
|
| 3 |
from diffusers import DiffusionPipeline, DPMSolverMultistepScheduler
|
| 4 |
from diffusers.utils import export_to_video
|
| 5 |
import uuid
|
|
|
|
| 6 |
|
| 7 |
+
# Model Yükleme
|
| 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)
|
|
|
|
| 12 |
|
| 13 |
def generate_video(prompt):
|
| 14 |
try:
|
| 15 |
+
# Kaliteyi koruyalım (Patronun istediği gibi net olsun)
|
| 16 |
+
# num_inference_steps=20 (Dengeli kalite)
|
|
|
|
| 17 |
frames = pipe(
|
| 18 |
prompt,
|
| 19 |
+
num_inference_steps=20,
|
| 20 |
height=320,
|
| 21 |
width=576,
|
| 22 |
+
num_frames=16
|
| 23 |
).frames
|
| 24 |
|
| 25 |
+
output_filename = f"viral_{uuid.uuid4()}.mp4"
|
| 26 |
+
export_to_video(frames[0], output_filename, fps=8)
|
| 27 |
+
|
| 28 |
+
# SADECE dosya adını döndür, Gradio bunu otomatik URL'ye çevirir
|
| 29 |
+
return output_filename
|
| 30 |
except Exception as e:
|
| 31 |
+
print(f"HATA: {str(e)}")
|
| 32 |
return None
|
| 33 |
|
| 34 |
+
# API İsmi: predict
|
| 35 |
demo = gr.Interface(fn=generate_video, inputs="text", outputs="video", api_name="predict")
|
| 36 |
demo.launch()
|