Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,16 +5,24 @@ import cv2
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def image_to_video(image):
|
| 8 |
-
image_array = np.array(image.convert('RGB')) # RGB๋ก ๋ณํ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
# MP4 ๋์ AVI ํ์ผ๋ก ์ ์ฅ์ ์๋ํด ๋ณด์ธ์.
|
| 11 |
-
output_path = '/mnt/data/output_video.avi'
|
| 12 |
height, width, _ = image_array.shape
|
| 13 |
size = (width, height)
|
| 14 |
-
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # 'mp4v' ์ฝ๋ฑ
|
| 15 |
|
| 16 |
video = cv2.VideoWriter(output_path, fourcc, 30, size) # ํ๋ ์ ์๋๋ฅผ 30์ผ๋ก ์ค์
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
for _ in range(150): # ์ด 150 ํ๋ ์ ์์ฑ
|
| 19 |
video.write(image_array)
|
| 20 |
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def image_to_video(image):
|
| 8 |
+
image_array = np.array(image.convert('RGB')) # ์ด๋ฏธ์ง๋ฅผ RGB๋ก ๋ณํ
|
| 9 |
+
|
| 10 |
+
# ํ์ผ ๊ฒฝ๋ก ์ง์
|
| 11 |
+
output_path = 'output_video.mp4' # ๊ฒฝ๋ก ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ๊ฐ์ํ๋ ๊ฒฝ๋ก ์ฌ์ฉ
|
| 12 |
+
if not os.path.exists('output'): # 'output' ๋๋ ํ ๋ฆฌ๊ฐ ์์ผ๋ฉด ์์ฑ
|
| 13 |
+
os.makedirs('output')
|
| 14 |
+
output_path = os.path.join('output', output_path) # ํ์ผ ๊ฒฝ๋ก ์์ฑ
|
| 15 |
|
|
|
|
|
|
|
| 16 |
height, width, _ = image_array.shape
|
| 17 |
size = (width, height)
|
| 18 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # 'mp4v' ์ฝ๋ฑ ์ฌ์ฉ
|
| 19 |
|
| 20 |
video = cv2.VideoWriter(output_path, fourcc, 30, size) # ํ๋ ์ ์๋๋ฅผ 30์ผ๋ก ์ค์
|
| 21 |
|
| 22 |
+
if not video.isOpened():
|
| 23 |
+
print("๋น๋์ค ์์ฑ์๊ฐ ํ์ผ์ ์ด์ง ๋ชปํ์ต๋๋ค.")
|
| 24 |
+
return None
|
| 25 |
+
|
| 26 |
for _ in range(150): # ์ด 150 ํ๋ ์ ์์ฑ
|
| 27 |
video.write(image_array)
|
| 28 |
|