Skip to content

Commit 3fc66d8

Browse files
committed
dataloader and input from puls
1 parent 3bc02b6 commit 3fc66d8

File tree

2 files changed

+22
-40
lines changed

2 files changed

+22
-40
lines changed

ns_vfs/api/run_with_nsvqa.py

Lines changed: 20 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import numpy as np
4+
import json
45
from cvias.image.detection.vllm_detection import VLLMDetection
56

67
from ns_vfs.automaton.video_automaton import VideoAutomaton
@@ -101,42 +102,23 @@ def run_nsvs_nsvqa(
101102

102103

103104
if __name__ == "__main__":
104-
video_path = "/nas/mars/dataset/LongVideoBench/videos/86CxyhFV9MI.mp4"
105-
subtitle_path = "/nas/mars/dataset/LongVideoBench/subtitles/86CxyhFV9MI_en.json"
106-
bench = LongVideoBench(video_path, subtitle_path)
105+
input_data_path = "/nas/mars/experiment_result/nsvqa/1_puls/longvideobench/longvideobench-outputs-updated.json"
106+
with open(input_data_path, 'r', encoding='utf-8') as f:
107+
data = json.load(f)
107108

108-
import sys
109-
sys.exit(0)
110-
sample_data = [
111-
{
112-
"frames": [
113-
# Create a 224x224x3 RGB image with some pattern
114-
np.random.randint(
115-
0, 255, (224, 224, 3), dtype=np.uint8
116-
), # Random RGB image
117-
np.random.randint(
118-
0, 255, (224, 224, 3), dtype=np.uint8
119-
), # Random RGB image
120-
],
121-
"subtitle": "test",
122-
},
123-
{
124-
"frames": [
125-
np.random.randint(
126-
0, 255, (224, 224, 3), dtype=np.uint8
127-
), # Random RGB image
128-
],
129-
"subtitle": "test",
130-
},
131-
]
132-
run_nsvs_nsvqa(
133-
nsvqa_input_data=sample_data,
134-
desired_interval_in_sec=None,
135-
desired_fps=30,
136-
proposition_set=["car", "truck"],
137-
ltl_formula='"car" U "truck"',
138-
output_path="/home/mc76728/repo/Coargus/Neuro-Symbolic-Video-Search-Temporal-Logic/_dev_",
139-
threshold_satisfaction_probability=0.80,
140-
frame_scale=None,
141-
calibration_method="temperature_scaling",
142-
)
109+
for sample in data:
110+
loader = LongVideoBench(sample["video_path"], sample["subtitle_path"])
111+
nsvqa_input = loader.load_all()
112+
extracted = sample["video_path"].split('/')[-1].split('.')[0]
113+
114+
run_nsvs_nsvqa(
115+
nsvqa_input_data=nsvqa_input,
116+
desired_interval_in_sec=None,
117+
desired_fps=30,
118+
proposition_set=sample["proposition"],
119+
ltl_formula=sample["specification"],
120+
output_path=f"/nas/mars/experiment_result/nsvqa/2_nsvs/longvideobench/{extracted}/",
121+
threshold_satisfaction_probability=0.80,
122+
frame_scale=None,
123+
calibration_method="temperature_scaling",
124+
)

ns_vfs/dataloader/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from typing import List, Dict, Union
12
import abc
23

3-
44
class DatasetLoader(abc.ABC):
55
"""Base class for loading dataset."""
66

@@ -9,6 +9,6 @@ def __init__(self, video_path: str, subtitle_path: str) -> None:
99
self.subtitle_path = subtitle_path
1010

1111
@abc.abstractmethod
12-
def load_all(self) -> any:
12+
def load_all(self) -> List[Dict[str, Union[List[np.ndarray], None]]]:
1313
"""Load video and subtitles."""
1414

0 commit comments

Comments
 (0)