MCPcopy Create free account
hub / github.com/InternScience/InternAgent / load_locomo_dataset

Function load_locomo_dataset

tasks/AutoMem/run_0/code/load_dataset.py:98–212  ·  view source on GitHub ↗

Load the LoComo dataset from a JSON file, including image-based content by using captions. Args: file_path: Path to the JSON file containing the dataset Returns: List of LoCoMoSample objects containing the parsed data

(file_path: Union[str, Path])

Source from the content-addressed store, hash-verified

96 )
97
98def load_locomo_dataset(file_path: Union[str, Path]) -> List[LoCoMoSample]:
99 """
100 Load the LoComo dataset from a JSON file, including image-based content by using captions.
101
102 Args:
103 file_path: Path to the JSON file containing the dataset
104
105 Returns:
106 List of LoCoMoSample objects containing the parsed data
107 """
108 if isinstance(file_path, str):
109 file_path = Path(file_path)
110
111 if not file_path.exists():
112 raise FileNotFoundError(f"Dataset file not found at {file_path}")
113
114 with open(file_path, 'r', encoding='utf-8') as f:
115 data = json.load(f)
116
117 samples = []
118 total_qa = 0
119 total_image_qa = 0
120 qa_counts_per_sample = []
121
122 for sample_idx, sample in enumerate(data):
123 try:
124 # Parse QA data
125 qa_list = []
126 sample_qa_count = 0
127 sample_image_qa_count = 0
128
129 for qa_idx, qa in enumerate(sample["qa"]):
130 try:
131 # Check if QA has image evidence
132 has_image_evidence = False
133 for evidence_id in qa.get("evidence", []):
134 if ":" not in evidence_id:
135 continue
136 turn_id = evidence_id.split(":")[1]
137 for session in sample["conversation"].values():
138 if isinstance(session, list):
139 for turn in session:
140 if turn.get("dia_id", "").endswith(turn_id):
141 if "img_url" in turn or "blip_caption" in turn:
142 has_image_evidence = True
143 break
144
145 if has_image_evidence:
146 sample_image_qa_count += 1
147
148 qa_obj = QA(
149 question=qa["question"],
150 answer=qa.get("answer"),
151 evidence=qa.get("evidence", []),
152 category=qa.get("category"),
153 adversarial_answer=qa.get("adversarial_answer")
154 )
155 qa_list.append(qa_obj)

Callers 2

evaluate_datasetFunction · 0.90
load_dataset.pyFile · 0.70

Calls 8

QAClass · 0.70
parse_conversationFunction · 0.70
EventSummaryClass · 0.70
ObservationClass · 0.70
LoCoMoSampleClass · 0.70
loadMethod · 0.45
getMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected