Delete MME-RealWorld-Base64.py
Browse files- MME-RealWorld-Base64.py +0 -30
MME-RealWorld-Base64.py
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
import json
|
2 |
-
import os
|
3 |
-
from datasets import Dataset, DatasetDict, Features, Value, Sequence
|
4 |
-
|
5 |
-
def load_json_lines(file_path):
|
6 |
-
with open(file_path, 'r') as f:
|
7 |
-
for line in f:
|
8 |
-
yield json.loads(line)
|
9 |
-
|
10 |
-
def _generate_examples(chunk_files):
|
11 |
-
for file in chunk_files:
|
12 |
-
for example in load_json_lines(file):
|
13 |
-
yield example['Question_id'], example
|
14 |
-
|
15 |
-
def load_dataset(*args, **kwargs):
|
16 |
-
dataset_dir = kwargs['data_dir'] # The directory containing JSON chunks
|
17 |
-
chunk_files = [os.path.join(dataset_dir, f) for f in os.listdir(dataset_dir) if f.endswith('.json')]
|
18 |
-
features = Features({
|
19 |
-
'index': Value(dtype='string'),
|
20 |
-
'image': Value(dtype='string'),
|
21 |
-
'question': Value(dtype='string'),
|
22 |
-
'multi-choice options': Sequence(Value(dtype='string')),
|
23 |
-
'answer': Value(dtype='string'),
|
24 |
-
'category': Value(dtype='string'),
|
25 |
-
'l2-category': Value(dtype='string'),
|
26 |
-
})
|
27 |
-
dataset = DatasetDict({
|
28 |
-
'train': Dataset.from_generator(lambda: _generate_examples(chunk_files), features=features)
|
29 |
-
})
|
30 |
-
return dataset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|