Spaces:
Running
Running
韩宇
commited on
Commit
·
7cd106f
1
Parent(s):
51e209e
opt
Browse files- agent/video_preprocessor/webpage_vp.py +8 -7
- db.db +0 -0
- video_cache/Build a Video Search and Summarization Agent blueprint by nvidia _ NVIDIA NIM - - 2024-11-15 18-35-47.mp4/video_cache.pkl +3 -0
- video_cache/Build a Video Search and Summarization Agent blueprint by nvidia _ NVIDIA NIM - - 2024-11-15 18-36-01.mp4/video_cache.pkl +3 -0
- video_cache/Build a Video Search and Summarization Agent blueprint by nvidia _ NVIDIA NIM.mp4/video_cache.pkl +3 -0
- webpage_process_video_understanding.json +23 -0
- webpage_video_understanding.json +122 -0
agent/video_preprocessor/webpage_vp.py
CHANGED
@@ -42,7 +42,7 @@ class WebpageVideoPreprocessor(BaseLLMBackend, BaseWorker):
|
|
42 |
kernel_size: Optional[int] = None
|
43 |
show_progress: bool = True
|
44 |
|
45 |
-
use_cache: bool =
|
46 |
cache_dir: str = "./video_cache"
|
47 |
|
48 |
@field_validator("stt", mode="before")
|
@@ -87,7 +87,7 @@ class WebpageVideoPreprocessor(BaseLLMBackend, BaseWorker):
|
|
87 |
|
88 |
cache_path = (
|
89 |
Path(self.cache_dir)
|
90 |
-
.joinpath(video_path.replace("/", "-"))
|
91 |
.joinpath("video_cache.pkl")
|
92 |
)
|
93 |
# Load video from cache if available
|
@@ -174,7 +174,8 @@ class WebpageVideoPreprocessor(BaseLLMBackend, BaseWorker):
|
|
174 |
pickle.dump(video.scenes, f)
|
175 |
|
176 |
# Process video if not loaded from cache
|
177 |
-
if not self.stm(self.workflow_instance_id).get("video", None):
|
|
|
178 |
video = VideoScenes.load(
|
179 |
video_path=video_path,
|
180 |
threshold=self.scene_detect_threshold,
|
@@ -241,10 +242,10 @@ class WebpageVideoPreprocessor(BaseLLMBackend, BaseWorker):
|
|
241 |
self.callback.error(f"Failed to process scene {index}: {e}")
|
242 |
scene.summary = None
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
return {
|
249 |
"video_md5": video_md5,
|
250 |
"video_path": video_path,
|
|
|
42 |
kernel_size: Optional[int] = None
|
43 |
show_progress: bool = True
|
44 |
|
45 |
+
use_cache: bool = True
|
46 |
cache_dir: str = "./video_cache"
|
47 |
|
48 |
@field_validator("stt", mode="before")
|
|
|
87 |
|
88 |
cache_path = (
|
89 |
Path(self.cache_dir)
|
90 |
+
.joinpath(Path(video_path).name.replace("/", "-"))
|
91 |
.joinpath("video_cache.pkl")
|
92 |
)
|
93 |
# Load video from cache if available
|
|
|
174 |
pickle.dump(video.scenes, f)
|
175 |
|
176 |
# Process video if not loaded from cache
|
177 |
+
# if not self.stm(self.workflow_instance_id).get("video", None):
|
178 |
+
if not cache_path.exists():
|
179 |
video = VideoScenes.load(
|
180 |
video_path=video_path,
|
181 |
threshold=self.scene_detect_threshold,
|
|
|
242 |
self.callback.error(f"Failed to process scene {index}: {e}")
|
243 |
scene.summary = None
|
244 |
|
245 |
+
if self.use_cache and not cache_path.exists():
|
246 |
+
cache_path.parent.mkdir(parents=True, exist_ok=True)
|
247 |
+
with open(cache_path, "wb") as f:
|
248 |
+
pickle.dump(video.scenes, f)
|
249 |
return {
|
250 |
"video_md5": video_md5,
|
251 |
"video_path": video_path,
|
db.db
ADDED
Binary file (111 kB). View file
|
|
video_cache/Build a Video Search and Summarization Agent blueprint by nvidia _ NVIDIA NIM - - 2024-11-15 18-35-47.mp4/video_cache.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:321ab99f6c22dfb8cabe2a69a733c9377ef5d5f37664e9ed7f05a15f16bac04c
|
3 |
+
size 2901
|
video_cache/Build a Video Search and Summarization Agent blueprint by nvidia _ NVIDIA NIM - - 2024-11-15 18-36-01.mp4/video_cache.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf531dcac5d926b1a4b9d5fa6ed69cb2f051894ab1582cdfc5de0ed40d85d250
|
3 |
+
size 4447
|
video_cache/Build a Video Search and Summarization Agent blueprint by nvidia _ NVIDIA NIM.mp4/video_cache.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d8b552fa7034b8d6fa7a85b410d971f6d1fa0fc1b1e3162a48aae05ebc7ed7f8
|
3 |
+
size 1514
|
webpage_process_video_understanding.json
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "webpage_process_video_understanding",
|
3 |
+
"tasks": [
|
4 |
+
{
|
5 |
+
"name": "WebpageVideoPreprocessor",
|
6 |
+
"taskReferenceName": "webpage_video_preprocess",
|
7 |
+
"inputParameters": {
|
8 |
+
"video_path": "${workflow.input.video_path}"
|
9 |
+
},
|
10 |
+
"type": "SIMPLE",
|
11 |
+
"taskDefinition": {}
|
12 |
+
}
|
13 |
+
],
|
14 |
+
"inputParameters": [],
|
15 |
+
"outputParameters": {},
|
16 |
+
"failureWorkflow": "",
|
17 |
+
"schemaVersion": 2,
|
18 |
+
"workflowStatusListenerEnabled": false,
|
19 |
+
"ownerEmail": "[email protected]",
|
20 |
+
"timeoutSeconds": 60,
|
21 |
+
"variables": {},
|
22 |
+
"inputTemplate": {}
|
23 |
+
}
|
webpage_video_understanding.json
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "webpage_video_understanding",
|
3 |
+
"tasks": [
|
4 |
+
{
|
5 |
+
"name": "WebpageVideoPreprocessor",
|
6 |
+
"taskReferenceName": "webpage_video_preprocess",
|
7 |
+
"inputParameters": {
|
8 |
+
"video_path": "${workflow.input.video_path}"
|
9 |
+
},
|
10 |
+
"type": "SIMPLE",
|
11 |
+
"taskDefinition": {}
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "WebpageVideoQA",
|
15 |
+
"taskReferenceName": "webpage_video_qa",
|
16 |
+
"inputParameters": {
|
17 |
+
"video_md5": "${workflow.input.video_md5}",
|
18 |
+
"video_path": "${workflow.input.video_path}",
|
19 |
+
"instance_id": "${workflow.input.instance_id}",
|
20 |
+
"question": "${workflow.input.question}"
|
21 |
+
},
|
22 |
+
"type": "SIMPLE",
|
23 |
+
"taskDefinition": {}
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"name": "ConstructDncPayload",
|
27 |
+
"taskReferenceName": "construct_dnc_payload",
|
28 |
+
"inputParameters": {
|
29 |
+
"query": "${webpage_video_qa.output.query}"
|
30 |
+
},
|
31 |
+
"type": "SIMPLE",
|
32 |
+
"taskDefinition": {}
|
33 |
+
},
|
34 |
+
{
|
35 |
+
"name": "dncloop_task",
|
36 |
+
"taskReferenceName": "dncloop_task",
|
37 |
+
"inputParameters": {},
|
38 |
+
"type": "DO_WHILE",
|
39 |
+
"taskDefinition": {},
|
40 |
+
"loopCondition": " if ( $.task_exit_monitor['exit_flag'] == true) { false; } else { true; }",
|
41 |
+
"loopOver": [
|
42 |
+
{
|
43 |
+
"name": "StructureUpdate",
|
44 |
+
"taskReferenceName": "structure_update",
|
45 |
+
"inputParameters": {
|
46 |
+
"dnc_structure": "${construct_dnc_payload.output.dnc_structure}"
|
47 |
+
},
|
48 |
+
"type": "SIMPLE"
|
49 |
+
},
|
50 |
+
{
|
51 |
+
"name": "TaskConqueror",
|
52 |
+
"taskReferenceName": "task_conqueror",
|
53 |
+
"inputParameters": {
|
54 |
+
"dnc_structure": "${structure_update.output.dnc_structure}",
|
55 |
+
"last_output": "${structure_update.output.last_output}"
|
56 |
+
},
|
57 |
+
"type": "SIMPLE"
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"name": "switch_task",
|
61 |
+
"taskReferenceName": "switch_task",
|
62 |
+
"inputParameters": {
|
63 |
+
"switchCaseValue": "${task_conqueror.output.switch_case_value}"
|
64 |
+
},
|
65 |
+
"type": "SWITCH",
|
66 |
+
"decisionCases": {
|
67 |
+
"complex": [
|
68 |
+
{
|
69 |
+
"name": "TaskDivider",
|
70 |
+
"taskReferenceName": "task_divider",
|
71 |
+
"inputParameters": {
|
72 |
+
"dnc_structure": "${task_conqueror.output.dnc_structure}",
|
73 |
+
"last_output": "${task_conqueror.output.last_output}"
|
74 |
+
},
|
75 |
+
"type": "SIMPLE"
|
76 |
+
}
|
77 |
+
],
|
78 |
+
"failed": [
|
79 |
+
{
|
80 |
+
"name": "TaskRescue",
|
81 |
+
"taskReferenceName": "task_rescue",
|
82 |
+
"inputParameters": {
|
83 |
+
"dnc_structure": "${task_conqueror.output.dnc_structure}",
|
84 |
+
"last_output": "${task_conqueror.output.last_output}"
|
85 |
+
},
|
86 |
+
"type": "SIMPLE"
|
87 |
+
}
|
88 |
+
]
|
89 |
+
},
|
90 |
+
"defaultCase": [],
|
91 |
+
"evaluatorType": "value-param",
|
92 |
+
"expression": "switchCaseValue"
|
93 |
+
},
|
94 |
+
{
|
95 |
+
"name": "TaskExitMonitor",
|
96 |
+
"taskReferenceName": "task_exit_monitor",
|
97 |
+
"inputParameters": {},
|
98 |
+
"type": "SIMPLE"
|
99 |
+
}
|
100 |
+
]
|
101 |
+
},
|
102 |
+
{
|
103 |
+
"name": "WebpageConclude",
|
104 |
+
"taskReferenceName": "webpage_task_conclude",
|
105 |
+
"inputParameters": {
|
106 |
+
"dnc_structure": "${task_exit_monitor.output.dnc_structure}",
|
107 |
+
"last_output": "${task_exit_monitor.output.last_output}"
|
108 |
+
},
|
109 |
+
"type": "SIMPLE",
|
110 |
+
"taskDefinition": {}
|
111 |
+
}
|
112 |
+
],
|
113 |
+
"inputParameters": [],
|
114 |
+
"outputParameters": {},
|
115 |
+
"failureWorkflow": "",
|
116 |
+
"schemaVersion": 2,
|
117 |
+
"workflowStatusListenerEnabled": false,
|
118 |
+
"ownerEmail": "[email protected]",
|
119 |
+
"timeoutSeconds": 60,
|
120 |
+
"variables": {},
|
121 |
+
"inputTemplate": {}
|
122 |
+
}
|