openfree commited on
Commit
9ac9ea2
Β·
verified Β·
1 Parent(s): 8a264b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -4
app.py CHANGED
@@ -635,26 +635,39 @@ def analyze_scenario(scenario):
635
  return ["Error occurred during analysis"] * 5
636
 
637
  def generate_section_video(prompt, preset, section_number=1, base_seed=171198, progress=gr.Progress()):
638
- """각 μ„Ήμ…˜μ˜ λΉ„λ””μ˜€ 생성 - μ—λŸ¬ 처리 μΆ”κ°€"""
639
  try:
640
  if not prompt or len(prompt.strip()) < 50:
641
  raise gr.Error("ν”„λ‘¬ν”„νŠΈλŠ” μ΅œμ†Œ 50자 이상이어야 ν•©λ‹ˆλ‹€.")
642
 
643
- selected = next(item for item in preset_options if item["label"] == preset)
 
 
 
 
 
 
644
  section_seed = base_seed + section_number
645
 
646
  return generate_video_from_text(
647
  prompt=prompt,
 
 
 
 
 
 
648
  height=selected["height"],
649
  width=selected["width"],
650
  num_frames=selected["num_frames"],
651
- seed=section_seed,
652
  progress=progress
653
  )
654
  except Exception as e:
655
  print(f"Error in section {section_number}: {e}")
656
  raise gr.Error(f"μ„Ήμ…˜ {section_number} 생성 쀑 였λ₯˜: {str(e)}")
657
-
 
 
658
 
659
  def generate_single_section_prompt(scenario, section_number):
660
  """κ°œλ³„ μ„Ήμ…˜μ— λŒ€ν•œ ν”„λ‘¬ν”„νŠΈ 생성"""
 
635
  return ["Error occurred during analysis"] * 5
636
 
637
  def generate_section_video(prompt, preset, section_number=1, base_seed=171198, progress=gr.Progress()):
638
+ """각 μ„Ήμ…˜μ˜ λΉ„λ””μ˜€ 생성"""
639
  try:
640
  if not prompt or len(prompt.strip()) < 50:
641
  raise gr.Error("ν”„λ‘¬ν”„νŠΈλŠ” μ΅œμ†Œ 50자 이상이어야 ν•©λ‹ˆλ‹€.")
642
 
643
+ if not preset:
644
+ raise gr.Error("해상도 프리셋을 μ„ νƒν•΄μ£Όμ„Έμš”.")
645
+
646
+ selected = next((item for item in preset_options if item["label"] == preset), None)
647
+ if not selected:
648
+ raise gr.Error("μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ ν”„λ¦¬μ…‹μž…λ‹ˆλ‹€.")
649
+
650
  section_seed = base_seed + section_number
651
 
652
  return generate_video_from_text(
653
  prompt=prompt,
654
+ enhance_prompt_toggle=False, # μ„Ήμ…˜ μƒμ„±μ‹œλŠ” ν”„λ‘¬ν”„νŠΈ 증강 λΉ„ν™œμ„±ν™”
655
+ negative_prompt="low quality, worst quality, deformed, distorted, warped",
656
+ frame_rate=25,
657
+ seed=section_seed,
658
+ num_inference_steps=41,
659
+ guidance_scale=4.0,
660
  height=selected["height"],
661
  width=selected["width"],
662
  num_frames=selected["num_frames"],
 
663
  progress=progress
664
  )
665
  except Exception as e:
666
  print(f"Error in section {section_number}: {e}")
667
  raise gr.Error(f"μ„Ήμ…˜ {section_number} 생성 쀑 였λ₯˜: {str(e)}")
668
+ finally:
669
+ torch.cuda.empty_cache()
670
+ gc.collect()
671
 
672
  def generate_single_section_prompt(scenario, section_number):
673
  """κ°œλ³„ μ„Ήμ…˜μ— λŒ€ν•œ ν”„λ‘¬ν”„νŠΈ 생성"""