Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Commit
โข
a0b6e16
1
Parent(s):
3bdb854
Update app.py
Browse files
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 |
-
|
16 |
-
|
17 |
-
|
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 |
# ์ด๋ฏธ์ง ์ํ์ค๋ก๋ถํฐ ๋น๋์ค ํด๋ฆฝ ์์ฑ ๋ฐ ๊ธฐํ ๋ก์ง...
|