halilcelik commited on
Commit
b18c415
·
verified ·
1 Parent(s): 52a2c18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -16
app.py CHANGED
@@ -9,45 +9,43 @@ import os
9
  model_id = "vdo/zeroscope_v2_576w"
10
 
11
  # Pipeline Hazırlığı
12
- print("Patron motoru ısıtıyorum, 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, emirlerini bekliyorum!")
17
 
18
  def generate_video(prompt):
19
  try:
20
- # KALİTE GÜNCELLEMESİ:
21
- # num_inference_steps: 3 -> 12 (Görüntü netleşecek)
22
- # num_frames: 6 -> 14 (Video süresi uzayacak)
23
- # height/width: 256 -> 320x576 (YouTube Shorts için daha uygun genişlik)
24
 
25
  frames = pipe(
26
  prompt,
27
  num_inference_steps=12,
28
- height=320,
29
- width=576,
30
- num_frames=14
31
  ).frames
32
 
33
  # Her video için benzersiz isim
34
- unique_name = f"result_{uuid.uuid4()}.mp4"
35
 
36
- # Video dışa aktarımı (FPS 8 olarak kaldı, daha akıcı görünür)
37
- export_to_video(frames[0], unique_name, fps=8)
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="Generated Video"),
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