Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,6 +6,7 @@ import gradio as gr
|
|
| 6 |
import typing
|
| 7 |
import time
|
| 8 |
import shutil
|
|
|
|
| 9 |
from moviepy.video.io.VideoFileClip import VideoFileClip, AudioFileClip
|
| 10 |
from moviepy.audio.AudioClip import CompositeAudioClip
|
| 11 |
from huggingface_hub import snapshot_download
|
|
@@ -44,12 +45,14 @@ DEFAULT_CLUE = "一位中年男性以沉稳但略带担忧的语调,分析我
|
|
| 44 |
model_pool: typing.Optional[GlobalModels] = None
|
| 45 |
engine = None
|
| 46 |
|
|
|
|
| 47 |
def init_engine():
|
| 48 |
"""延迟加载模型,避免启动时卡住"""
|
| 49 |
global engine
|
| 50 |
engine = AutoFrontend(PRETRAIN, CONFIG_MODEL, TEMP_DIR, DEVICE)
|
| 51 |
return engine
|
| 52 |
|
|
|
|
| 53 |
def init_frontend_models():
|
| 54 |
global model_pool
|
| 55 |
model_pool = GlobalModels(
|
|
@@ -138,6 +141,7 @@ def load_srt_fn(srt_file, current_count):
|
|
| 138 |
|
| 139 |
return [new_count] + updates + vis + [btn]
|
| 140 |
|
|
|
|
| 141 |
def process_dubbing(video_file, *segment_inputs, progress=gr.Progress()):
|
| 142 |
"""主推理流程"""
|
| 143 |
if not video_file:
|
|
|
|
| 6 |
import typing
|
| 7 |
import time
|
| 8 |
import shutil
|
| 9 |
+
import spaces
|
| 10 |
from moviepy.video.io.VideoFileClip import VideoFileClip, AudioFileClip
|
| 11 |
from moviepy.audio.AudioClip import CompositeAudioClip
|
| 12 |
from huggingface_hub import snapshot_download
|
|
|
|
| 45 |
model_pool: typing.Optional[GlobalModels] = None
|
| 46 |
engine = None
|
| 47 |
|
| 48 |
+
@spaces.GPU
|
| 49 |
def init_engine():
|
| 50 |
"""延迟加载模型,避免启动时卡住"""
|
| 51 |
global engine
|
| 52 |
engine = AutoFrontend(PRETRAIN, CONFIG_MODEL, TEMP_DIR, DEVICE)
|
| 53 |
return engine
|
| 54 |
|
| 55 |
+
@spaces.GPU
|
| 56 |
def init_frontend_models():
|
| 57 |
global model_pool
|
| 58 |
model_pool = GlobalModels(
|
|
|
|
| 141 |
|
| 142 |
return [new_count] + updates + vis + [btn]
|
| 143 |
|
| 144 |
+
@spaces.GPU
|
| 145 |
def process_dubbing(video_file, *segment_inputs, progress=gr.Progress()):
|
| 146 |
"""主推理流程"""
|
| 147 |
if not video_file:
|