openfree commited on
Commit
40f5b5d
ยท
verified ยท
1 Parent(s): 27e4a3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -3
app.py CHANGED
@@ -562,7 +562,7 @@ def process_video_bg(vid, bg_type="์ƒ‰์ƒ", bg_image=None, bg_video=None, color=
562
  print(f"Error: {e}")
563
  elapsed_time = time.time() - start_time
564
  yield gr.update(visible=False), gr.update(visible=True), f"๋น„๋””์˜ค ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜: {e}. ๊ฒฝ๊ณผ ์‹œ๊ฐ„: {elapsed_time:.2f}์ดˆ"
565
- yield None, f"๋น„๋””์˜ค ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜: {e}", f"๋น„๋””์˜ค ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜: {e}. ๊ฒฝ๊ณผ ์‹œ๊ฐ„: {elapsed_time:.2f}์ดˆ"
566
 
567
  @spaces.GPU
568
  def merge_videos_with_audio(video_files, audio_file, audio_volume, output_fps):
@@ -570,7 +570,7 @@ def merge_videos_with_audio(video_files, audio_file, audio_volume, output_fps):
570
  if not video_files:
571
  return None, "๋น„๋””์˜ค ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”."
572
 
573
- if len(video_files) > 10:
574
  return None, "์ตœ๋Œ€ 10๊ฐœ์˜ ๋น„๋””์˜ค๋งŒ ์—…๋กœ๋“œ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."
575
 
576
  try:
@@ -677,6 +677,18 @@ def merge_videos_with_audio(video_files, audio_file, audio_volume, output_fps):
677
  logging.error(f"Video merge error: {str(e)}")
678
  return None, f"โŒ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
679
 
 
 
 
 
 
 
 
 
 
 
 
 
680
  # CSS
681
  css = """
682
  :root {
@@ -1143,4 +1155,5 @@ try:
1143
  except:
1144
  pass
1145
 
1146
- demo.launch()
 
 
562
  print(f"Error: {e}")
563
  elapsed_time = time.time() - start_time
564
  yield gr.update(visible=False), gr.update(visible=True), f"๋น„๋””์˜ค ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜: {e}. ๊ฒฝ๊ณผ ์‹œ๊ฐ„: {elapsed_time:.2f}์ดˆ"
565
+ yield None, None, f"๋น„๋””์˜ค ์ฒ˜๋ฆฌ ์˜ค๋ฅ˜: {e}. ๊ฒฝ๊ณผ ์‹œ๊ฐ„: {elapsed_time:.2f}์ดˆ"
566
 
567
  @spaces.GPU
568
  def merge_videos_with_audio(video_files, audio_file, audio_volume, output_fps):
 
570
  if not video_files:
571
  return None, "๋น„๋””์˜ค ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”."
572
 
573
+ if isinstance(video_files, list) and len(video_files) > 10:
574
  return None, "์ตœ๋Œ€ 10๊ฐœ์˜ ๋น„๋””์˜ค๋งŒ ์—…๋กœ๋“œ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค."
575
 
576
  try:
 
677
  logging.error(f"Video merge error: {str(e)}")
678
  return None, f"โŒ ์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
679
 
680
+ # GPU ์ดˆ๊ธฐํ™” ํ•จ์ˆ˜ ์ถ”๊ฐ€
681
+ def dummy_gpu_init():
682
+ """GPU ์ดˆ๊ธฐํ™”๋ฅผ ์œ„ํ•œ ๋”๋ฏธ ํ•จ์ˆ˜"""
683
+ if torch.cuda.is_available():
684
+ try:
685
+ # ๊ฐ„๋‹จํ•œ ํ…์„œ ์—ฐ์‚ฐ์œผ๋กœ GPU ์ดˆ๊ธฐํ™”
686
+ dummy_tensor = torch.zeros(1).to(device)
687
+ del dummy_tensor
688
+ logging.info("GPU initialized successfully")
689
+ except Exception as e:
690
+ logging.warning(f"GPU initialization warning: {e}")
691
+
692
  # CSS
693
  css = """
694
  :root {
 
1155
  except:
1156
  pass
1157
 
1158
+ if __name__ == "__main__":
1159
+ demo.launch()