Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,27 @@
|
|
| 1 |
import spaces, os
|
| 2 |
import gradio as gr
|
|
|
|
| 3 |
|
| 4 |
from demo.infer import LiveCCDemoInfer
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
class GradioBackend:
|
| 9 |
-
waiting_video_response = 'Waiting for video input...'
|
| 10 |
-
not_found_video_response = 'Video does not exist...'
|
| 11 |
-
mode2api = {
|
| 12 |
-
'Real-Time Commentary': 'live_cc',
|
| 13 |
-
'Conversation': 'video_qa'
|
| 14 |
-
}
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
gr.Markdown("## LiveCC Real-Time Commentary and Conversation - Gradio Demo")
|
| 29 |
gr.Markdown("### [LiveCC: Learning Video LLM with Streaming Speech Transcription at Scale (CVPR 2025)](https://showlab.github.io/livecc/)")
|
|
@@ -60,8 +58,12 @@ with gr.Blocks() as demo:
|
|
| 60 |
with gr.Row():
|
| 61 |
gr_radio_mode = gr.Radio(label="Select Mode", choices=["Real-Time Commentary", "Conversation"], elem_id="gr_radio_mode", value='Real-Time Commentary', interactive=True)
|
| 62 |
|
|
|
|
| 63 |
def gr_chatinterface_fn(message, history, state, video_path, mode):
|
| 64 |
state['video_path'] = video_path
|
|
|
|
|
|
|
|
|
|
| 65 |
response, state = gradio_backend(query=message, state=state, mode=mode)
|
| 66 |
return response, state
|
| 67 |
def gr_chatinterface_chatbot_clear_fn():
|
|
|
|
| 1 |
import spaces, os
|
| 2 |
import gradio as gr
|
| 3 |
+
from kokoro import KPipeline
|
| 4 |
|
| 5 |
from demo.infer import LiveCCDemoInfer
|
| 6 |
|
| 7 |
+
model_path = 'chenjoya/LiveCC-7B-Instruct'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
class GradioBackend:
|
| 10 |
+
waiting_video_response = 'Waiting for video input...'
|
| 11 |
+
not_found_video_response = 'Video does not exist...'
|
| 12 |
+
mode2api = {
|
| 13 |
+
'Real-Time Commentary': 'live_cc',
|
| 14 |
+
'Conversation': 'video_qa'
|
| 15 |
+
}
|
| 16 |
|
| 17 |
+
def __init__(self, infer, audio_pipeline):
|
| 18 |
+
self.infer = infer
|
| 19 |
+
self.audio_pipeline = 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 |
|
| 26 |
gr.Markdown("## LiveCC Real-Time Commentary and Conversation - Gradio Demo")
|
| 27 |
gr.Markdown("### [LiveCC: Learning Video LLM with Streaming Speech Transcription at Scale (CVPR 2025)](https://showlab.github.io/livecc/)")
|
|
|
|
| 58 |
with gr.Row():
|
| 59 |
gr_radio_mode = gr.Radio(label="Select Mode", choices=["Real-Time Commentary", "Conversation"], elem_id="gr_radio_mode", value='Real-Time Commentary', interactive=True)
|
| 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():
|