Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import random
|
|
| 7 |
from PIL import Image
|
| 8 |
from transparent_background import Remover
|
| 9 |
import subprocess
|
|
|
|
| 10 |
|
| 11 |
@spaces.GPU()
|
| 12 |
def doo(video, mode):
|
|
@@ -21,9 +22,9 @@ def doo(video, mode):
|
|
| 21 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 22 |
|
| 23 |
tmpname = random.randint(111111111, 999999999)
|
| 24 |
-
tmp_video = f"{tmpname}_video.mp4"
|
| 25 |
-
tmp_audio = f"{tmpname}_audio.aac"
|
| 26 |
-
output_video = f"{tmpname}_output.mp4"
|
| 27 |
|
| 28 |
writer = cv2.VideoWriter(tmp_video, cv2.VideoWriter_fourcc(*'mp4v'), fps, (width, height))
|
| 29 |
|
|
@@ -58,12 +59,12 @@ def doo(video, mode):
|
|
| 58 |
subprocess.call(['ffmpeg', '-i', tmp_video, '-i', tmp_audio, '-c', 'copy', output_video])
|
| 59 |
|
| 60 |
# ์์ ํ์ผ ์ญ์
|
| 61 |
-
|
|
|
|
| 62 |
|
| 63 |
return output_video
|
| 64 |
|
| 65 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
| 66 |
-
examples = [['./input.mp4'],]
|
| 67 |
css = """footer { visibility: hidden; }"""
|
| 68 |
|
| 69 |
b_interface = gr.Interface(
|
|
@@ -73,8 +74,11 @@ b_interface = gr.Interface(
|
|
| 73 |
gr.Radio(['Normal', 'Fast'], label='Select mode', value='Normal', info='Normal is more accurate, but takes longer. | Fast has lower accuracy so the process will be faster.')
|
| 74 |
],
|
| 75 |
outputs="video",
|
| 76 |
-
examples=examples,
|
| 77 |
css=css,
|
| 78 |
title="Video Background Removal",
|
| 79 |
description="Select a video and mode to remove the background."
|
| 80 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
from PIL import Image
|
| 8 |
from transparent_background import Remover
|
| 9 |
import subprocess
|
| 10 |
+
import os
|
| 11 |
|
| 12 |
@spaces.GPU()
|
| 13 |
def doo(video, mode):
|
|
|
|
| 22 |
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
| 23 |
|
| 24 |
tmpname = random.randint(111111111, 999999999)
|
| 25 |
+
tmp_video = f"/tmp/{tmpname}_video.mp4"
|
| 26 |
+
tmp_audio = f"/tmp/{tmpname}_audio.aac"
|
| 27 |
+
output_video = f"/tmp/{tmpname}_output.mp4"
|
| 28 |
|
| 29 |
writer = cv2.VideoWriter(tmp_video, cv2.VideoWriter_fourcc(*'mp4v'), fps, (width, height))
|
| 30 |
|
|
|
|
| 59 |
subprocess.call(['ffmpeg', '-i', tmp_video, '-i', tmp_audio, '-c', 'copy', output_video])
|
| 60 |
|
| 61 |
# ์์ ํ์ผ ์ญ์
|
| 62 |
+
os.remove(tmp_video)
|
| 63 |
+
os.remove(tmp_audio)
|
| 64 |
|
| 65 |
return output_video
|
| 66 |
|
| 67 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
|
|
|
| 68 |
css = """footer { visibility: hidden; }"""
|
| 69 |
|
| 70 |
b_interface = gr.Interface(
|
|
|
|
| 74 |
gr.Radio(['Normal', 'Fast'], label='Select mode', value='Normal', info='Normal is more accurate, but takes longer. | Fast has lower accuracy so the process will be faster.')
|
| 75 |
],
|
| 76 |
outputs="video",
|
|
|
|
| 77 |
css=css,
|
| 78 |
title="Video Background Removal",
|
| 79 |
description="Select a video and mode to remove the background."
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
# Gradio ์ฑ ์คํ
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
+
b_interface.launch()
|