Spaces:
Running
Running
gg
Browse files- app.py +7 -5
- inference.py +1 -0
app.py
CHANGED
@@ -70,9 +70,12 @@ with gr.Blocks(title="VideoLLM-online", css=css) as demo:
|
|
70 |
gr_video_time = gr.Number(value=0, visible=False)
|
71 |
gr_liveinfer_queue_refresher = gr.Number(value=False, visible=False)
|
72 |
|
73 |
-
def
|
74 |
name, ext = os.path.splitext(src_video_path)
|
75 |
ffmpeg_video_path = os.path.join('demo/assets/cache', name + f'_{liveinfer.frame_fps}fps_{liveinfer.frame_resolution}' + ext)
|
|
|
|
|
|
|
76 |
if not os.path.exists(ffmpeg_video_path):
|
77 |
os.makedirs(os.path.dirname(ffmpeg_video_path), exist_ok=True)
|
78 |
ffmpeg_once(src_video_path, ffmpeg_video_path, fps=liveinfer.frame_fps, resolution=liveinfer.frame_resolution)
|
@@ -83,14 +86,13 @@ with gr.Blocks(title="VideoLLM-online", css=css) as demo:
|
|
83 |
if query or response:
|
84 |
history.append((query, response))
|
85 |
return history, video_time + 1 / liveinfer.frame_fps, not gate
|
86 |
-
gr_video.
|
87 |
-
|
88 |
outputs=[gr_chat_interface.chatbot, gr_video_time, gr_liveinfer_queue_refresher]
|
89 |
)
|
90 |
|
91 |
def gr_video_time_change(_, video_time):
|
92 |
-
|
93 |
-
video_time += 1/30
|
94 |
liveinfer.input_video_stream(video_time)
|
95 |
print(video_time)
|
96 |
return video_time
|
|
|
70 |
gr_video_time = gr.Number(value=0, visible=False)
|
71 |
gr_liveinfer_queue_refresher = gr.Number(value=False, visible=False)
|
72 |
|
73 |
+
def gr_video_change(src_video_path, history, video_time, gate):
|
74 |
name, ext = os.path.splitext(src_video_path)
|
75 |
ffmpeg_video_path = os.path.join('demo/assets/cache', name + f'_{liveinfer.frame_fps}fps_{liveinfer.frame_resolution}' + ext)
|
76 |
+
if ffmpeg_video_path == liveinfer.video_path:
|
77 |
+
return
|
78 |
+
liveinfer.video_path = ffmpeg_video_path
|
79 |
if not os.path.exists(ffmpeg_video_path):
|
80 |
os.makedirs(os.path.dirname(ffmpeg_video_path), exist_ok=True)
|
81 |
ffmpeg_once(src_video_path, ffmpeg_video_path, fps=liveinfer.frame_fps, resolution=liveinfer.frame_resolution)
|
|
|
86 |
if query or response:
|
87 |
history.append((query, response))
|
88 |
return history, video_time + 1 / liveinfer.frame_fps, not gate
|
89 |
+
gr_video.change(
|
90 |
+
gr_video_change, inputs=[gr_video, gr_chat_interface.chatbot, gr_video_time, gr_liveinfer_queue_refresher],
|
91 |
outputs=[gr_chat_interface.chatbot, gr_video_time, gr_liveinfer_queue_refresher]
|
92 |
)
|
93 |
|
94 |
def gr_video_time_change(_, video_time):
|
95 |
+
video_time += 1 / liveinfer.frame_fps
|
|
|
96 |
liveinfer.input_video_stream(video_time)
|
97 |
print(video_time)
|
98 |
return video_time
|
inference.py
CHANGED
@@ -85,6 +85,7 @@ class LiveInfer:
|
|
85 |
def reset(self, ):
|
86 |
self.query_queue = collections.deque()
|
87 |
self.frame_embeds_queue = collections.deque()
|
|
|
88 |
self.video_time = 0
|
89 |
self.last_frame_idx = -1
|
90 |
self.video_tensor = None
|
|
|
85 |
def reset(self, ):
|
86 |
self.query_queue = collections.deque()
|
87 |
self.frame_embeds_queue = collections.deque()
|
88 |
+
self.video_path = None
|
89 |
self.video_time = 0
|
90 |
self.last_frame_idx = -1
|
91 |
self.video_tensor = None
|