Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,31 @@
|
|
1 |
-
import os, torchvision, transformers
|
2 |
from functools import partial
|
3 |
import gradio as gr
|
4 |
|
5 |
-
from
|
6 |
-
|
7 |
-
from .inference import LiveInfer
|
8 |
logger = transformers.logging.get_logger('liveinfer')
|
9 |
|
10 |
# python -m demo.app --resume_from_checkpoint ...
|
11 |
|
12 |
liveinfer = LiveInfer()
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
css = """
|
15 |
#gr_title {text-align: center;}
|
16 |
#gr_video {max-height: 480px;}
|
|
|
1 |
+
import os, torchvision, transformers, subprocess
|
2 |
from functools import partial
|
3 |
import gradio as gr
|
4 |
|
5 |
+
from inference import LiveInfer
|
|
|
|
|
6 |
logger = transformers.logging.get_logger('liveinfer')
|
7 |
|
8 |
# python -m demo.app --resume_from_checkpoint ...
|
9 |
|
10 |
liveinfer = LiveInfer()
|
11 |
|
12 |
+
def ffmpeg_once(src_path: str, dst_path: str, *, fps: int = None, resolution: int = None, pad: str = '#000000', mode='bicubic'):
|
13 |
+
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
|
14 |
+
command = [
|
15 |
+
'./ffmpeg/ffmpeg',
|
16 |
+
'-y',
|
17 |
+
'-sws_flags', mode,
|
18 |
+
'-i', src_path,
|
19 |
+
'-an',
|
20 |
+
'-threads', '10',
|
21 |
+
]
|
22 |
+
if fps is not None:
|
23 |
+
command += ['-r', str(fps)]
|
24 |
+
if resolution is not None:
|
25 |
+
command += ['-vf', f"scale='if(gt(iw\\,ih)\\,{resolution}\\,-2)':'if(gt(iw\\,ih)\\,-2\\,{resolution})',pad={resolution}:{resolution}:(ow-iw)/2:(oh-ih)/2:color='{pad}'"]
|
26 |
+
command += [dst_path]
|
27 |
+
subprocess.run(command, check=True)
|
28 |
+
|
29 |
css = """
|
30 |
#gr_title {text-align: center;}
|
31 |
#gr_video {max-height: 480px;}
|