seawolf2357 commited on
Commit
a0b6e16
โ€ข
1 Parent(s): 3bdb854

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -2,23 +2,24 @@ import gradio as gr
2
  from moviepy.editor import ImageSequenceClip
3
  import tempfile
4
  import os
 
 
5
 
6
  def images_to_video(image_files):
7
- # ์ž„์‹œ ๋””๋ ‰ํ„ฐ๋ฆฌ ์ƒ์„ฑ
8
  temp_dir = tempfile.mkdtemp()
9
-
10
  image_paths = []
 
11
  for i, image_file in enumerate(image_files):
12
- # ์—…๋กœ๋“œ๋œ ํŒŒ์ผ์ด ์ด๋ฏธ ํŒŒ์ผ ๊ฒฝ๋กœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฌธ์ž์—ด์ธ ๊ฒฝ์šฐ,
13
- # ํ•ด๋‹น ๊ฒฝ๋กœ๋ฅผ ์ด๋ฏธ์ง€ ๊ฒฝ๋กœ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€
14
  image_path = os.path.join(temp_dir, f"image_{i}.png")
15
- if isinstance(image_file, str):
16
- # ์—ฌ๊ธฐ์„œ image_file์€ ์ด๋ฏธ ํŒŒ์ผ ๊ฒฝ๋กœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋ฏ€๋กœ, ๋ณ„๋„์˜ ์ฒ˜๋ฆฌ ์—†์ด ์‚ฌ์šฉ
17
- shutil.copy(image_file, image_path)
18
- else:
19
- # image_file์ด ๋ฐ”์ดํŠธ ๋ฐ์ดํ„ฐ๋ฅผ ํฌํ•จํ•˜๋Š” ๊ฒฝ์šฐ, ํŒŒ์ผ๋กœ ์“ฐ๊ธฐ
20
  with open(image_path, "wb") as f:
21
  f.write(image_file)
 
 
 
 
22
  image_paths.append(image_path)
23
 
24
  # ์ด๋ฏธ์ง€ ์‹œํ€€์Šค๋กœ๋ถ€ํ„ฐ ๋น„๋””์˜ค ํด๋ฆฝ ์ƒ์„ฑ ๋ฐ ๊ธฐํƒ€ ๋กœ์ง...
 
2
  from moviepy.editor import ImageSequenceClip
3
  import tempfile
4
  import os
5
+ import shutil # ์ด ๋ถ€๋ถ„์„ ์ถ”๊ฐ€
6
+
7
 
8
  def images_to_video(image_files):
 
9
  temp_dir = tempfile.mkdtemp()
 
10
  image_paths = []
11
+
12
  for i, image_file in enumerate(image_files):
 
 
13
  image_path = os.path.join(temp_dir, f"image_{i}.png")
14
+
15
+ # ํŒŒ์ผ ๋‚ด์šฉ์„ ๋ฐ”์ดํŠธ๋กœ ์“ฐ๊ฑฐ๋‚˜ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” ํŒŒ์ผ์„ ๋ณต์‚ฌ
16
+ if isinstance(image_file, bytes):
 
 
17
  with open(image_path, "wb") as f:
18
  f.write(image_file)
19
+ else:
20
+ # shutil ๋ชจ๋“ˆ์˜ copy ํ•จ์ˆ˜ ์‚ฌ์šฉ
21
+ shutil.copy(image_file, image_path)
22
+
23
  image_paths.append(image_path)
24
 
25
  # ์ด๋ฏธ์ง€ ์‹œํ€€์Šค๋กœ๋ถ€ํ„ฐ ๋น„๋””์˜ค ํด๋ฆฝ ์ƒ์„ฑ ๋ฐ ๊ธฐํƒ€ ๋กœ์ง...