chenjoya commited on
Commit
c1771c7
·
verified ·
1 Parent(s): fdcc35d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -3,28 +3,28 @@ import gradio as gr
3
 
4
  from demo.infer import LiveCCDemoInfer
5
 
6
- class GradioBackend:
7
- waiting_video_response = 'Waiting for video input...'
8
- not_found_video_response = 'Video does not exist...'
9
- mode2api = {
10
- 'Real-Time Commentary': 'live_cc',
11
- 'Conversation': 'video_qa'
12
- }
13
 
14
- @spaces.GPU
15
- def __init__(self, model_path: str = 'chenjoya/LiveCC-7B-Instruct'):
16
- os.system('pip install flash-attn --no-build-isolation')
17
- self.infer = LiveCCDemoInfer(model_path)
18
- from kokoro import KPipeline
19
- self.audio_pipeline = KPipeline(lang_code='a')
 
20
 
21
- @spaces.GPU
22
- def __call__(self, query: str = None, state: dict = {}, mode: str = 'Real-Time Commentary', **kwargs):
23
- return getattr(self.infer, self.mode2api[mode])(query=query, state=state, **kwargs)
 
 
24
 
25
- gradio_backend = GradioBackend()
 
 
 
 
26
 
27
- with gr.Blocks() as demo:
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/)")
30
  gr.Markdown("1️⃣ Select Mode, Real-Time Commentary (LiveCC) or Conversation (Common QA)")
 
3
 
4
  from demo.infer import LiveCCDemoInfer
5
 
6
+ with gr.Blocks() as demo:
 
 
 
 
 
 
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
+ @spaces.GPU
17
+ def __init__(self, model_path: str = 'chenjoya/LiveCC-7B-Instruct'):
18
+ self.infer = LiveCCDemoInfer(model_path)
19
+ from kokoro import KPipeline
20
+ self.audio_pipeline = KPipeline(lang_code='a')
21
 
22
+ @spaces.GPU
23
+ def __call__(self, query: str = None, state: dict = {}, mode: str = 'Real-Time Commentary', **kwargs):
24
+ return getattr(self.infer, self.mode2api[mode])(query=query, state=state, **kwargs)
25
+
26
+ gradio_backend = GradioBackend()
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/)")
30
  gr.Markdown("1️⃣ Select Mode, Real-Time Commentary (LiveCC) or Conversation (Common QA)")