Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -14,12 +14,17 @@ class GradioBackend:
|
|
14 |
'Conversation': 'video_qa'
|
15 |
}
|
16 |
|
17 |
-
def __init__(self,
|
18 |
-
self.infer =
|
19 |
-
self.audio_pipeline =
|
20 |
|
21 |
def __call__(self, query: str = None, state: dict = {}, mode: str = 'Real-Time Commentary', **kwargs):
|
22 |
return getattr(self.infer, self.mode2api[mode])(query=query, state=state, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
with gr.Blocks() as demo:
|
25 |
|
@@ -60,10 +65,8 @@ with gr.Blocks() as demo:
|
|
60 |
|
61 |
@spaces.GPU
|
62 |
def gr_chatinterface_fn(message, history, state, video_path, mode):
|
|
|
63 |
state['video_path'] = video_path
|
64 |
-
infer = LiveCCDemoInfer(model_path)
|
65 |
-
audio_pipeline = KPipeline(lang_code='a')
|
66 |
-
gradio_backend = GradioBackend(infer, audio_pipeline)
|
67 |
response, state = gradio_backend(query=message, state=state, mode=mode)
|
68 |
return response, state
|
69 |
def gr_chatinterface_chatbot_clear_fn():
|
|
|
14 |
'Conversation': 'video_qa'
|
15 |
}
|
16 |
|
17 |
+
def __init__(self, ):
|
18 |
+
self.infer = LiveCCDemoInfer(model_path, device='cpu')
|
19 |
+
self.audio_pipeline = KPipeline(lang_code='a')
|
20 |
|
21 |
def __call__(self, query: str = None, state: dict = {}, mode: str = 'Real-Time Commentary', **kwargs):
|
22 |
return getattr(self.infer, self.mode2api[mode])(query=query, state=state, **kwargs)
|
23 |
+
|
24 |
+
def to(self, device):
|
25 |
+
self.infer.model.to(device)
|
26 |
+
|
27 |
+
gradio_backend = GradioBackend()
|
28 |
|
29 |
with gr.Blocks() as demo:
|
30 |
|
|
|
65 |
|
66 |
@spaces.GPU
|
67 |
def gr_chatinterface_fn(message, history, state, video_path, mode):
|
68 |
+
gradio_backend.to('cuda')
|
69 |
state['video_path'] = video_path
|
|
|
|
|
|
|
70 |
response, state = gradio_backend(query=message, state=state, mode=mode)
|
71 |
return response, state
|
72 |
def gr_chatinterface_chatbot_clear_fn():
|