ginipick commited on
Commit
c57854a
ยท
verified ยท
1 Parent(s): 47816f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
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
- video = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'mp4v'), 30, size)
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()