halilcelik commited on
Commit
128f7ac
·
verified ·
1 Parent(s): b18c415

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -30
app.py CHANGED
@@ -5,49 +5,31 @@ from diffusers.utils import export_to_video
5
  import uuid
6
  import os
7
 
8
- # Model Tanımlama
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
-
52
- if __name__ == "__main__":
53
- demo.launch()
 
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
+ # KALİTEYİ MAKSİMUMA ÇIKARDIK:
16
+ # num_inference_steps=25 (Şekiller netleşecek)
17
+ # num_frames=24 (Video 3 saniye olacak)
18
+ # Çözünürlüğü biraz daha artırdık
 
19
  frames = pipe(
20
  prompt,
21
+ num_inference_steps=25,
22
+ height=320,
23
+ width=576,
24
+ num_frames=24
25
  ).frames
26
 
 
27
  unique_name = f"viral_{uuid.uuid4()}.mp4"
28
+ export_to_video(frames[0], unique_name, fps=8)
 
 
 
29
  return os.path.abspath(unique_name)
 
30
  except Exception as e:
31
+ print(f"HATA: {e}")
32
  return None
33
 
34
+ demo = gr.Interface(fn=generate_video, inputs="text", outputs="video", api_name="predict")
35
+ demo.launch()