Spaces:
Running
Running
tori29umai
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,7 @@ def process_image(image_path):
|
|
25 |
width = int(height * aspect_ratio)
|
26 |
image = image.resize((width, height), Image.ANTIALIAS)
|
27 |
|
28 |
-
#
|
29 |
fps = 30
|
30 |
duration = 5
|
31 |
total_frames = fps * duration
|
@@ -37,8 +37,8 @@ def process_image(image_path):
|
|
37 |
frame = np.array(image)
|
38 |
frames.append(frame)
|
39 |
|
40 |
-
#
|
41 |
-
output_video_path =
|
42 |
|
43 |
# 動画ファイルにフレームを保存
|
44 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # MP4形式
|
@@ -51,6 +51,7 @@ def process_image(image_path):
|
|
51 |
|
52 |
video_writer.release()
|
53 |
|
|
|
54 |
return output_video_path
|
55 |
|
56 |
class WebUI:
|
@@ -70,7 +71,7 @@ class WebUI:
|
|
70 |
with gr.Row():
|
71 |
with gr.Column():
|
72 |
with gr.Tab("Output"):
|
73 |
-
output_mp4 = gr.
|
74 |
submit.click(self.main, inputs=[input_image], outputs=[output_mp4])
|
75 |
|
76 |
self.demo.queue()
|
|
|
25 |
width = int(height * aspect_ratio)
|
26 |
image = image.resize((width, height), Image.ANTIALIAS)
|
27 |
|
28 |
+
# 動画のフレーム数(30fpsで5秒分)
|
29 |
fps = 30
|
30 |
duration = 5
|
31 |
total_frames = fps * duration
|
|
|
37 |
frame = np.array(image)
|
38 |
frames.append(frame)
|
39 |
|
40 |
+
# 動画保存先の一時ファイルパス
|
41 |
+
output_video_path = "/tmp/output_video.mp4"
|
42 |
|
43 |
# 動画ファイルにフレームを保存
|
44 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # MP4形式
|
|
|
51 |
|
52 |
video_writer.release()
|
53 |
|
54 |
+
# 動画ファイルをGradioに返す
|
55 |
return output_video_path
|
56 |
|
57 |
class WebUI:
|
|
|
71 |
with gr.Row():
|
72 |
with gr.Column():
|
73 |
with gr.Tab("Output"):
|
74 |
+
output_mp4 = gr.Video()
|
75 |
submit.click(self.main, inputs=[input_image], outputs=[output_mp4])
|
76 |
|
77 |
self.demo.queue()
|