Update app.py
Browse files
app.py
CHANGED
|
@@ -9,45 +9,43 @@ import os
|
|
| 9 |
model_id = "vdo/zeroscope_v2_576w"
|
| 10 |
|
| 11 |
# Pipeline Hazırlığı
|
| 12 |
-
print("Patron
|
| 13 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 14 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 15 |
pipe.to("cpu")
|
| 16 |
-
print("Motor hazır, emirlerini bekliyorum!")
|
| 17 |
|
| 18 |
def generate_video(prompt):
|
| 19 |
try:
|
| 20 |
-
#
|
| 21 |
-
# num_inference_steps
|
| 22 |
-
# num_frames
|
| 23 |
-
# height/width
|
| 24 |
|
| 25 |
frames = pipe(
|
| 26 |
prompt,
|
| 27 |
num_inference_steps=12,
|
| 28 |
-
height=
|
| 29 |
-
width=
|
| 30 |
-
num_frames=
|
| 31 |
).frames
|
| 32 |
|
| 33 |
# Her video için benzersiz isim
|
| 34 |
-
unique_name = f"
|
| 35 |
|
| 36 |
-
# Video dışa aktarımı (FPS
|
| 37 |
-
export_to_video(frames[0], unique_name, fps=
|
| 38 |
|
| 39 |
-
# n8n'in dosyayı çekebilmesi için tam yol
|
| 40 |
return os.path.abspath(unique_name)
|
| 41 |
|
| 42 |
except Exception as e:
|
| 43 |
print(f"HATA ALDIK PATRON: {e}")
|
| 44 |
return None
|
| 45 |
|
| 46 |
-
# API İsmi: 'predict' olarak sabitlendi, n8n direkt buraya vuracak
|
| 47 |
demo = gr.Interface(
|
| 48 |
fn=generate_video,
|
| 49 |
-
inputs=gr.Textbox(label="Video Prompt"),
|
| 50 |
-
outputs=gr.Video(label="
|
| 51 |
api_name="predict"
|
| 52 |
)
|
| 53 |
|
|
|
|
| 9 |
model_id = "vdo/zeroscope_v2_576w"
|
| 10 |
|
| 11 |
# Pipeline Hazırlığı
|
| 12 |
+
print("Patron komedi dükkanını açıyoruz, model yükleniyor...")
|
| 13 |
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
|
| 14 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
| 15 |
pipe.to("cpu")
|
| 16 |
+
print("Motor hazır, kahkahalar için emirlerini bekliyorum!")
|
| 17 |
|
| 18 |
def generate_video(prompt):
|
| 19 |
try:
|
| 20 |
+
# KOMEDİ AYARLARI:
|
| 21 |
+
# num_inference_steps=12 (Detaylar için)
|
| 22 |
+
# num_frames=20 (Daha uzun ve hareketli bir sahne için artırdık)
|
| 23 |
+
# height/width=448x256 (Dikey Shorts formatı)
|
| 24 |
|
| 25 |
frames = pipe(
|
| 26 |
prompt,
|
| 27 |
num_inference_steps=12,
|
| 28 |
+
height=448,
|
| 29 |
+
width=256,
|
| 30 |
+
num_frames=20
|
| 31 |
).frames
|
| 32 |
|
| 33 |
# Her video için benzersiz isim
|
| 34 |
+
unique_name = f"viral_{uuid.uuid4()}.mp4"
|
| 35 |
|
| 36 |
+
# Video dışa aktarımı (FPS 10 yaparak hareketi hızlandırdık, daha komik durur)
|
| 37 |
+
export_to_video(frames[0], unique_name, fps=10)
|
| 38 |
|
|
|
|
| 39 |
return os.path.abspath(unique_name)
|
| 40 |
|
| 41 |
except Exception as e:
|
| 42 |
print(f"HATA ALDIK PATRON: {e}")
|
| 43 |
return None
|
| 44 |
|
|
|
|
| 45 |
demo = gr.Interface(
|
| 46 |
fn=generate_video,
|
| 47 |
+
inputs=gr.Textbox(label="Viral Video Prompt"),
|
| 48 |
+
outputs=gr.Video(label="Funny Result"),
|
| 49 |
api_name="predict"
|
| 50 |
)
|
| 51 |
|