Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,24 +5,23 @@ import cv2
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def image_to_video(image):
|
| 8 |
-
image_array = np.array(image)
|
|
|
|
| 9 |
output_path = '/mnt/data/output_video.mp4'
|
| 10 |
-
|
| 11 |
-
height, width, layers = image_array.shape
|
| 12 |
size = (width, height)
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
for _ in range(150): # ์ด 150 ํ๋ ์ ์์ฑ
|
| 16 |
video.write(image_array)
|
| 17 |
-
|
| 18 |
-
video.release()
|
| 19 |
-
|
| 20 |
-
return output_path
|
| 21 |
|
|
|
|
| 22 |
|
|
|
|
| 23 |
|
| 24 |
def setup_interface():
|
| 25 |
-
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ
|
| 26 |
with gr.Blocks() as demo:
|
| 27 |
gr.Markdown("### ์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด 5์ด์ง๋ฆฌ ๋น๋์ค๋ฅผ ์์ฑํฉ๋๋ค.")
|
| 28 |
|
|
@@ -34,6 +33,5 @@ def setup_interface():
|
|
| 34 |
|
| 35 |
return demo
|
| 36 |
|
| 37 |
-
# ์ธํฐํ์ด์ค ์คํ
|
| 38 |
demo = setup_interface()
|
| 39 |
demo.launch()
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def image_to_video(image):
|
| 8 |
+
image_array = np.array(image.convert('RGB')) # RGB๋ก ๋ณํ
|
| 9 |
+
|
| 10 |
output_path = '/mnt/data/output_video.mp4'
|
| 11 |
+
height, width, _ = image_array.shape
|
|
|
|
| 12 |
size = (width, height)
|
| 13 |
+
fourcc = cv2.VideoWriter_fourcc(*'X264') # X264 ์ฝ๋ฑ ์ฌ์ฉ
|
| 14 |
+
|
| 15 |
+
video = cv2.VideoWriter(output_path, fourcc, 30, size) # ํ๋ ์ ์๋๋ฅผ 30์ผ๋ก ์ค์
|
| 16 |
+
|
| 17 |
for _ in range(150): # ์ด 150 ํ๋ ์ ์์ฑ
|
| 18 |
video.write(image_array)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
video.release()
|
| 21 |
|
| 22 |
+
return output_path
|
| 23 |
|
| 24 |
def setup_interface():
|
|
|
|
| 25 |
with gr.Blocks() as demo:
|
| 26 |
gr.Markdown("### ์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด 5์ด์ง๋ฆฌ ๋น๋์ค๋ฅผ ์์ฑํฉ๋๋ค.")
|
| 27 |
|
|
|
|
| 33 |
|
| 34 |
return demo
|
| 35 |
|
|
|
|
| 36 |
demo = setup_interface()
|
| 37 |
demo.launch()
|