Spaces:
Runtime error
Runtime error
process time
Browse files
app.py
CHANGED
@@ -6,6 +6,7 @@ from decord import VideoReader, cpu
|
|
6 |
import base64
|
7 |
import io
|
8 |
import spaces
|
|
|
9 |
|
10 |
# Load model
|
11 |
model_path = 'openbmb/MiniCPM-V-2_6'
|
@@ -44,6 +45,8 @@ def encode_video(video_path):
|
|
44 |
|
45 |
@spaces.GPU
|
46 |
def analyze_video(prompt, video):
|
|
|
|
|
47 |
if isinstance(video, str):
|
48 |
video_path = video
|
49 |
else:
|
@@ -69,7 +72,10 @@ def analyze_video(prompt, video):
|
|
69 |
|
70 |
response = model.chat(image=None, msgs=context, tokenizer=tokenizer, **params)
|
71 |
|
72 |
-
|
|
|
|
|
|
|
73 |
|
74 |
with gr.Blocks() as demo:
|
75 |
gr.Markdown("# Video Analyzer")
|
@@ -78,7 +84,7 @@ with gr.Blocks() as demo:
|
|
78 |
prompt_input = gr.Textbox(label="Prompt")
|
79 |
video_input = gr.Video(label="Upload Video")
|
80 |
with gr.Column():
|
81 |
-
output = gr.Textbox(label="Analysis Result")
|
82 |
|
83 |
analyze_button = gr.Button("Analyze Video")
|
84 |
analyze_button.click(fn=analyze_video, inputs=[prompt_input, video_input], outputs=output)
|
|
|
6 |
import base64
|
7 |
import io
|
8 |
import spaces
|
9 |
+
import time
|
10 |
|
11 |
# Load model
|
12 |
model_path = 'openbmb/MiniCPM-V-2_6'
|
|
|
45 |
|
46 |
@spaces.GPU
|
47 |
def analyze_video(prompt, video):
|
48 |
+
start_time = time.time()
|
49 |
+
|
50 |
if isinstance(video, str):
|
51 |
video_path = video
|
52 |
else:
|
|
|
72 |
|
73 |
response = model.chat(image=None, msgs=context, tokenizer=tokenizer, **params)
|
74 |
|
75 |
+
end_time = time.time()
|
76 |
+
processing_time = end_time - start_time
|
77 |
+
|
78 |
+
return f"Analysis Result:\n{response}\n\nProcessing Time: {processing_time:.2f} seconds"
|
79 |
|
80 |
with gr.Blocks() as demo:
|
81 |
gr.Markdown("# Video Analyzer")
|
|
|
84 |
prompt_input = gr.Textbox(label="Prompt")
|
85 |
video_input = gr.Video(label="Upload Video")
|
86 |
with gr.Column():
|
87 |
+
output = gr.Textbox(label="Analysis Result and Processing Time")
|
88 |
|
89 |
analyze_button = gr.Button("Analyze Video")
|
90 |
analyze_button.click(fn=analyze_video, inputs=[prompt_input, video_input], outputs=output)
|