Spaces:
Sleeping
Sleeping
v1
Browse files- app.py +0 -1
- config.py +0 -57
- loader/create_eval_dataset.py +0 -410
- utils/ddp_accel_bf16.yaml +0 -16
- utils/ddp_accel_fp16.yaml +0 -16
- utils/ds_accel_fp16.yaml +0 -23
app.py
CHANGED
@@ -4,7 +4,6 @@ import spaces
|
|
4 |
import time
|
5 |
import torch
|
6 |
import gradio as gr
|
7 |
-
from config import *
|
8 |
from PIL import Image
|
9 |
from utils.utils import *
|
10 |
from threading import Thread
|
|
|
4 |
import time
|
5 |
import torch
|
6 |
import gradio as gr
|
|
|
7 |
from PIL import Image
|
8 |
from utils.utils import *
|
9 |
from threading import Thread
|
config.py
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
# OpenAI Key
|
2 |
-
OPENAI_KEY = ""
|
3 |
-
|
4 |
-
# Dataset root
|
5 |
-
DATASET_ROOT=""
|
6 |
-
|
7 |
-
# Pre Meteor Dataset
|
8 |
-
METEOR_DATASET= "Meteor.json"
|
9 |
-
|
10 |
-
# Various json and parquet files
|
11 |
-
SHAREGPT4V_CAPTION = "sharegpt4v_instruct_gpt4-vision_cap100k.json"
|
12 |
-
SHAREGPT4V_INSTRUCTION = "sharegpt4v_mix665k_cap23k_coco-ap9k_lcs3k_sam9k_div2k.json"
|
13 |
-
MINIGEMINI_INSTRUCTION = "minigemini_instruction.json"
|
14 |
-
DOCDOWNSTREAM = 'train.jsonl'
|
15 |
-
DOCREASON = 'detailed_explanation.jsonl'
|
16 |
-
GLLAVA_ALIGN = "gllava_align.parquet"
|
17 |
-
GLLAVA_QA = "gllava_qa.parquet"
|
18 |
-
MATHVISION = "mathvision.parquet"
|
19 |
-
MATHINSTRUCT = "MathInstruct.json"
|
20 |
-
MATHPLUS = "mathplus.parquet"
|
21 |
-
|
22 |
-
# Json files for Evaluation
|
23 |
-
VQAV2 = "VQAv2/v2_OpenEnded_mscoco_test2015_questions.json"
|
24 |
-
GQA = "gqa/testdev_balanced_questions.json"
|
25 |
-
SQA = "ScienceQA/problems.json"
|
26 |
-
SQA_SPLIT = "ScienceQA/pid_splits.json"
|
27 |
-
VIZWIZ = "VizWiz/test.json"
|
28 |
-
TEXTVQA = "TextVQA/llava_textvqa_val_v051_ocr.json"
|
29 |
-
TEXTVQA_ANNOTATIONS = "TextVQA/TextVQA_0.5.1_val.json"
|
30 |
-
POPE_POPULAR = "POPE/coco_pope_popular.json"
|
31 |
-
POPE_ADVERSARIAL = "POPE/coco_pope_adversarial.json"
|
32 |
-
POPE_RANDOM = "POPE/coco_pope_random.json"
|
33 |
-
MME = "MME_Benchmark_release_version/llava_mme.json"
|
34 |
-
MME_DIR = "MME_Benchmark_release_version"
|
35 |
-
MMBENCH = "MMBench/MMBench_TEST_EN_legacy.tsv"
|
36 |
-
MMBENCH_CN = "MMBench/MMBench_TEST_CN_legacy.tsv"
|
37 |
-
MMBENCH_DEV = "MMBench/mmbench_dev_20230712.tsv"
|
38 |
-
MMBENCH_CN_DEV = "MMBench/mmbench_dev_cn_20231003.tsv"
|
39 |
-
QBENCH = "LLVisionQA-QBench/llvisionqa_dev.json"
|
40 |
-
QBENCH_CN = "LLVisionQA-QBench/质衡-问答-验证集.json"
|
41 |
-
MMVET = "mm-vet/mm-vet.json"
|
42 |
-
MMMU = "MMMU/*/validation*"
|
43 |
-
MATHVISTA = "MathVista/testmini-00000-of-00001-725687bf7a18d64b.parquet"
|
44 |
-
AI2D = "ai2d/ai2d_test.json"
|
45 |
-
HALLUSIONBENCH = "HallusionBench/HallusionBench.json"
|
46 |
-
CHARTQA = "chartqa/test/test_augmented.json"
|
47 |
-
SEED = "SEED-Bench/SEED-Bench.json"
|
48 |
-
LLAVA = "llava-bench-in-the-wild/questions.jsonl"
|
49 |
-
# BLINK =
|
50 |
-
MATHVERSE = "MathVerse/testmini.json"
|
51 |
-
MATHVERSE_TEXT_ONLY = "MathVerse/testmini_text_only.json"
|
52 |
-
MMSTAR = "MMStar/mmstar.parquet"
|
53 |
-
|
54 |
-
# Available evaluation datasets
|
55 |
-
EVAL_DATASETS = ["qbench", "sqa", "ai2d", "chartqa", "seed", "pope", "hallusionbench", "mme", \
|
56 |
-
"mathvista", "mmbench", "mmbench_cn", "mmvet", "llava", "mmstar", "mathverse"]
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loader/create_eval_dataset.py
DELETED
@@ -1,410 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import json
|
3 |
-
import math
|
4 |
-
import glob
|
5 |
-
from config import *
|
6 |
-
from PIL import Image
|
7 |
-
import pandas as pd
|
8 |
-
import pyarrow.parquet as pq
|
9 |
-
import torch.nn.functional as F
|
10 |
-
from eval.utils import *
|
11 |
-
from torch.utils.data import Dataset
|
12 |
-
from torchvision.transforms.functional import pil_to_tensor
|
13 |
-
|
14 |
-
class CreateEvalDataset(Dataset):
|
15 |
-
def __init__(self):
|
16 |
-
super(CreateEvalDataset, self).__init__()
|
17 |
-
|
18 |
-
"""
|
19 |
-
Eval Datasets
|
20 |
-
|
21 |
-
- VQAv2
|
22 |
-
- GQA
|
23 |
-
- SQA-IMG
|
24 |
-
- VizWiz
|
25 |
-
- TextVQA
|
26 |
-
- POPE
|
27 |
-
- MME
|
28 |
-
- MMBench
|
29 |
-
- MMBench-CN
|
30 |
-
- QBench
|
31 |
-
- MM-Vet
|
32 |
-
- MMMU
|
33 |
-
- MathVista
|
34 |
-
- AI2D
|
35 |
-
- HallusionBench
|
36 |
-
- ChartQA
|
37 |
-
- SEED
|
38 |
-
- LLaVA Wild
|
39 |
-
- BLINK
|
40 |
-
- MathVerse
|
41 |
-
|
42 |
-
"""
|
43 |
-
|
44 |
-
# dataset root path
|
45 |
-
self.dataset_root_path = DATASET_ROOT
|
46 |
-
|
47 |
-
# load test data
|
48 |
-
pre_vqav2 = json.load(open(os.path.join(DATASET_ROOT, VQAV2)))
|
49 |
-
pre_gqa = json.load(open(os.path.join(DATASET_ROOT, GQA)))
|
50 |
-
pre_sqa = json.load(open(os.path.join(DATASET_ROOT, SQA)))
|
51 |
-
pre_sqa_split = json.load(open(os.path.join(DATASET_ROOT, SQA_SPLIT)))
|
52 |
-
pre_vizwiz = json.load(open(os.path.join(DATASET_ROOT, VIZWIZ)))
|
53 |
-
pre_textvqa = json.load(open(os.path.join(DATASET_ROOT, TEXTVQA)))
|
54 |
-
pre_textvqa_annotations = json.load(open(os.path.join(DATASET_ROOT, TEXTVQA_ANNOTATIONS)))
|
55 |
-
pre_pope_popular = pd.read_json(os.path.join(DATASET_ROOT, POPE_POPULAR), lines=True)
|
56 |
-
pre_pope_adversarial= pd.read_json(os.path.join(DATASET_ROOT, POPE_ADVERSARIAL), lines=True)
|
57 |
-
pre_pope_random = pd.read_json(os.path.join(DATASET_ROOT, POPE_RANDOM), lines=True)
|
58 |
-
pre_mme = json.load(open(os.path.join(DATASET_ROOT, MME)))
|
59 |
-
pre_mmbench = pd.read_table(os.path.join(DATASET_ROOT, MMBENCH))
|
60 |
-
pre_mmbench_dev = pd.read_table(os.path.join(DATASET_ROOT, MMBENCH_DEV))
|
61 |
-
pre_mmbench_cn = pd.read_table(os.path.join(DATASET_ROOT, MMBENCH_CN))
|
62 |
-
pre_mmbench_cn_dev = pd.read_table(os.path.join(DATASET_ROOT, MMBENCH_CN_DEV))
|
63 |
-
pre_qbench = json.load(open(os.path.join(DATASET_ROOT, QBENCH)))
|
64 |
-
pre_qbench_cn = json.load(open(os.path.join(DATASET_ROOT, QBENCH_CN)))
|
65 |
-
pre_mmvet = json.load(open(os.path.join(DATASET_ROOT, MMVET)))
|
66 |
-
mmmu_files = glob.glob(os.path.join(DATASET_ROOT, MMMU))
|
67 |
-
pre_mmmu = [pq.read_pandas(os.path.join(DATASET_ROOT, mf)).to_pandas() for mf in mmmu_files]
|
68 |
-
pre_mathvista1 = pq.read_pandas(os.path.join(DATASET_ROOT, MATHVISTA)).to_pandas()
|
69 |
-
pre_ai2d = json.load(open(os.path.join(DATASET_ROOT, AI2D)))
|
70 |
-
pre_hallusionbench = json.load(open(os.path.join(DATASET_ROOT, HALLUSIONBENCH)))
|
71 |
-
pre_chartqa = json.load(open(os.path.join(DATASET_ROOT, CHARTQA)))
|
72 |
-
pre_seed = json.load(open(os.path.join(DATASET_ROOT, SEED)))
|
73 |
-
pre_llava = pd.read_json(os.path.join(DATASET_ROOT, LLAVA), lines=True)
|
74 |
-
# pre_blink = json.load(open(os.path.join(DATASET_ROOT, BLINK)))
|
75 |
-
pre_mathverse = json.load(open(os.path.join(DATASET_ROOT, MATHVERSE)))
|
76 |
-
pre_mathverse_text_only = json.load(open(os.path.join(DATASET_ROOT, MATHVERSE_TEXT_ONLY)))
|
77 |
-
pre_mmstar = pq.read_pandas(os.path.join(DATASET_ROOT, MMSTAR)).to_pandas()
|
78 |
-
|
79 |
-
# data filtering
|
80 |
-
vqav2 = self.vqav2_filtering(pre_vqav2)
|
81 |
-
gqa = self.gqa_filtering(pre_gqa)
|
82 |
-
sqa = self.sqa_filtering(pre_sqa, pre_sqa_split)
|
83 |
-
vizwiz = self.vizwiz_filtering(pre_vizwiz)
|
84 |
-
textvqa = self.textvqa_filtering(pre_textvqa, pre_textvqa_annotations)
|
85 |
-
pope = self.pope_filtering([pre_pope_popular, pre_pope_adversarial, pre_pope_random])
|
86 |
-
mme = self.mme_filtering(pre_mme)
|
87 |
-
mmbench = self.mmbench_filtering(pre_mmbench)
|
88 |
-
mmbench_dev = self.mmbench_filtering(pre_mmbench_dev)
|
89 |
-
mmbench_cn = self.mmbench_filtering(pre_mmbench_cn)
|
90 |
-
mmbench_cn_dev = self.mmbench_filtering(pre_mmbench_cn_dev)
|
91 |
-
qbench = self.qbench_filtering(pre_qbench)
|
92 |
-
qbench_cn = self.qbench_filtering(pre_qbench_cn)
|
93 |
-
mmvet = self.mmvet_filtering(pre_mmvet)
|
94 |
-
mmmu = self.mmmu_filtering(pre_mmmu)
|
95 |
-
mathvista = self.mathvista_filtering(pre_mathvista1)
|
96 |
-
ai2d = self.ai2d_filtering(pre_ai2d)
|
97 |
-
hallusionbench = self.hallusionbench_filtering(pre_hallusionbench)
|
98 |
-
chartqa = self.chartqa_filtering(pre_chartqa)
|
99 |
-
seed = self.seed_filtering(pre_seed)
|
100 |
-
llava = self.llava_filtering(pre_llava)
|
101 |
-
# blink = self.blink_filtering(pre_blink)
|
102 |
-
mathverse = self.mathverse_filtering(pre_mathverse, pre_mathverse_text_only)
|
103 |
-
mmstar = self.mmstar_filtering(pre_mmstar)
|
104 |
-
|
105 |
-
# merging
|
106 |
-
self.data = {
|
107 |
-
'vqav2': vqav2,
|
108 |
-
'gqa': gqa,
|
109 |
-
'sqa':sqa,
|
110 |
-
'vizwiz': vizwiz,
|
111 |
-
'textvqa': textvqa,
|
112 |
-
'pope': pope,
|
113 |
-
'mme': mme,
|
114 |
-
'mmbench': mmbench,
|
115 |
-
'mmbench_dev': mmbench_dev,
|
116 |
-
'mmbench_cn': mmbench_cn,
|
117 |
-
'mmbench_cn_dev': mmbench_cn_dev,
|
118 |
-
'qbench': qbench,
|
119 |
-
'mm-vet': mmvet,
|
120 |
-
'mmmu': mmmu,
|
121 |
-
'mathvista': mathvista,
|
122 |
-
'ai2d': ai2d,
|
123 |
-
'hallusionbench': hallusionbench,
|
124 |
-
'chartqa': chartqa,
|
125 |
-
'seed': seed,
|
126 |
-
'llava': llava,
|
127 |
-
# 'blink': blink,
|
128 |
-
'mathverse' : mathverse,
|
129 |
-
'mmstar' : mmstar
|
130 |
-
}
|
131 |
-
|
132 |
-
|
133 |
-
def vqav2_filtering(self, pre_data):
|
134 |
-
data = []
|
135 |
-
for x in pre_data['questions']:
|
136 |
-
data.append({'image': f"VQAv2/test2015/COCO_test2015_{x['image_id']:012d}.jpg",
|
137 |
-
'question': x['question'],
|
138 |
-
'id': x['question_id']})
|
139 |
-
return data
|
140 |
-
|
141 |
-
def gqa_filtering(self, pre_data):
|
142 |
-
data = []
|
143 |
-
for qid, x in pre_data.items():
|
144 |
-
data.append({'image': f"gqa/images/{x['imageId']}.jpg",
|
145 |
-
'question': x['question'],
|
146 |
-
'id': qid})
|
147 |
-
return data
|
148 |
-
|
149 |
-
def sqa_filtering(self, pre_data, pre_sqa_split):
|
150 |
-
data = []
|
151 |
-
questions = {idx: pre_data[idx] for idx in pre_sqa_split['test']}
|
152 |
-
for qid, x in questions.items():
|
153 |
-
if x['image'] is not None:
|
154 |
-
choices = '\n'.join(f"{chr(ord('A') + i)}. {choice}" for i, choice in enumerate(x['choices']))
|
155 |
-
question = '\n'.join([x['hint'], x['question'], choices])
|
156 |
-
data.append({'image': f"ScienceQA/images/test/{qid}/image.png",
|
157 |
-
'question': question,
|
158 |
-
'id': qid,
|
159 |
-
'candidates': x['choices'],
|
160 |
-
'gt': x['answer']})
|
161 |
-
return data
|
162 |
-
|
163 |
-
def vizwiz_filtering(self, pre_data):
|
164 |
-
data = []
|
165 |
-
for qid, x in enumerate(pre_data):
|
166 |
-
data.append({'image': f"VizWiz/test/{x['image']}",
|
167 |
-
'question': x['question'],
|
168 |
-
'id': qid})
|
169 |
-
return data
|
170 |
-
|
171 |
-
def textvqa_filtering(self, pre_data, annotations):
|
172 |
-
data = []
|
173 |
-
for x, answer in zip(pre_data, annotations['data']):
|
174 |
-
data.append({'image': f"TextVQA/train_images/{x['image']}",
|
175 |
-
'question': x['text'],
|
176 |
-
'id': x['question_id'],
|
177 |
-
'gt': answer['answers']})
|
178 |
-
return data
|
179 |
-
|
180 |
-
def pope_filtering(self, pre_data):
|
181 |
-
data = []
|
182 |
-
categories = ['adversarial', 'popular', 'random']
|
183 |
-
for category, split in zip(categories, pre_data):
|
184 |
-
for _, x in split.iterrows():
|
185 |
-
data.append({'image': f"coco2014/val2014/{x['image']}",
|
186 |
-
'question': x['text'],
|
187 |
-
'id': x['question_id'],
|
188 |
-
'category': category})
|
189 |
-
return data
|
190 |
-
|
191 |
-
def mme_filtering(self, pre_data):
|
192 |
-
data = []
|
193 |
-
for x in pre_data:
|
194 |
-
data.append({'image': f"MME_Benchmark_release_version/{x['image']}",
|
195 |
-
'question': x['text'],
|
196 |
-
'id': x['question_id'],
|
197 |
-
'category': x['category']})
|
198 |
-
return data
|
199 |
-
|
200 |
-
def mmbench_filtering(self, pre_data):
|
201 |
-
data = []
|
202 |
-
for _, x in pre_data.iterrows():
|
203 |
-
options = ['A', 'B', 'C', 'D']
|
204 |
-
choice_list = [choice for choice in options if not self.is_none(x[choice])]
|
205 |
-
choices = '\n'.join(f"{chr(ord('A') + i)}. {x[choice]}" for i, choice in enumerate(choice_list))
|
206 |
-
question = '\n'.join([x['question'], choices])
|
207 |
-
|
208 |
-
if not self.is_none(x['hint']):
|
209 |
-
question = '\n'.join([x['hint'], question])
|
210 |
-
|
211 |
-
data.append({'image': x['image'],
|
212 |
-
'question': question,
|
213 |
-
'id': x['index'],
|
214 |
-
'answer': x['answer'] if 'answer' in x else None})
|
215 |
-
return data
|
216 |
-
|
217 |
-
def qbench_filtering(self, pre_data):
|
218 |
-
data = []
|
219 |
-
for qid, x in enumerate(pre_data):
|
220 |
-
choices = '\n'.join(f"{chr(ord('A') + i)}. {choice}" for i, choice in enumerate(x['candidates']))
|
221 |
-
question = '\n'.join([x['question'], choices])
|
222 |
-
data.append({'image': f"LLVisionQA-QBench/images/{x['img_path']}",
|
223 |
-
'question': question,
|
224 |
-
'id': qid,
|
225 |
-
'candidates': x['candidates'],
|
226 |
-
'gt': x['correct_ans']})
|
227 |
-
return data
|
228 |
-
|
229 |
-
def mmvet_filtering(self, pre_data):
|
230 |
-
data = []
|
231 |
-
for qid, x in pre_data.items():
|
232 |
-
data.append({'image': f"mm-vet/images/{x['imagename']}",
|
233 |
-
'question': x['question'],
|
234 |
-
'id': qid,
|
235 |
-
'gt': x['answer'],
|
236 |
-
'capability': x['capability']})
|
237 |
-
return data
|
238 |
-
|
239 |
-
def mmmu_filtering(self, pre_data):
|
240 |
-
data = []
|
241 |
-
for split in pre_data:
|
242 |
-
for _, x in split.iterrows():
|
243 |
-
index2ans, all_choices = self.get_multi_choice_info(eval(x['options']))
|
244 |
-
choices = ' '.join([f"{k}. {v}" for k,v in index2ans.items()])
|
245 |
-
question = '\n'.join([x['question'], choices])
|
246 |
-
num_images = count_unique_image_tokens(question)
|
247 |
-
data.append({'images': [x[f"image_{i+1}"]['bytes'] for i in range(num_images)],
|
248 |
-
'question': replace_image_tokens(question),
|
249 |
-
'id': x['id'],
|
250 |
-
'question_type': x['question_type'],
|
251 |
-
'gt': x['answer'],
|
252 |
-
'index2ans': index2ans,
|
253 |
-
'all_choices': all_choices})
|
254 |
-
return data
|
255 |
-
|
256 |
-
def mathvista_filtering(self, pre_data):
|
257 |
-
data = []
|
258 |
-
for _, x in pre_data.iterrows():
|
259 |
-
skills = x['metadata']['skills'].tolist()
|
260 |
-
x['metadata']['skills'] = skills
|
261 |
-
choices = x['choices'].tolist() if x['choices'] is not None else None
|
262 |
-
data.append({'image': f"MathVista/{x['image']}",
|
263 |
-
'question': x['query'],
|
264 |
-
'question_type': x['question_type'],
|
265 |
-
'answer': x['answer'],
|
266 |
-
'answer_type': x['answer_type'],
|
267 |
-
'choices': choices,
|
268 |
-
'metadata': x['metadata'],
|
269 |
-
'precision': x['precision'],
|
270 |
-
'id': x['pid']})
|
271 |
-
return data
|
272 |
-
|
273 |
-
def ai2d_filtering(self, pre_data):
|
274 |
-
data = []
|
275 |
-
for x in pre_data:
|
276 |
-
choices = ' '.join(f"{chr(ord('A') + i)}. {choice}" for i, choice in enumerate(x["metadata"]["answerTexts"]))
|
277 |
-
question = '\n'.join([x['question'], choices])
|
278 |
-
image = f"ai2d/abc_images/{x['imageName']}" if x['metadata']['abcLabel'] else f"ai2d/images/{x['imageName']}"
|
279 |
-
data.append({'image': image,
|
280 |
-
'question': question,
|
281 |
-
'id': x['metadata']['questionId'],
|
282 |
-
'gt': x['metadata']['correctAnswer']})
|
283 |
-
return data
|
284 |
-
|
285 |
-
def hallusionbench_filtering(self, pre_data):
|
286 |
-
data = []
|
287 |
-
for qid, x in enumerate(pre_data):
|
288 |
-
if x['filename'] is None:
|
289 |
-
img_path = ""
|
290 |
-
question = x['question']
|
291 |
-
else:
|
292 |
-
img_path = f"HallusionBench/hallusion_bench/{x['filename'][2:]}".format()
|
293 |
-
question = "<image>" + x['question']
|
294 |
-
data.append({'image': img_path,
|
295 |
-
'question': question,
|
296 |
-
'id': qid,
|
297 |
-
'gt': x['gt_answer']})
|
298 |
-
return data
|
299 |
-
|
300 |
-
def chartqa_filtering(self, pre_data):
|
301 |
-
data = []
|
302 |
-
for qid, x in enumerate(pre_data):
|
303 |
-
data.append({'image': f"chartqa/test/png/{x['imgname']}",
|
304 |
-
'question': x['query'],
|
305 |
-
'id': x['imgname'],
|
306 |
-
'gt': x['label']})
|
307 |
-
return data
|
308 |
-
|
309 |
-
def seed_filtering(self, pre_data):
|
310 |
-
data = []
|
311 |
-
for x in pre_data['questions']:
|
312 |
-
if x['data_type'] != 'image':
|
313 |
-
continue
|
314 |
-
choice_list = [key for key in x.keys() if 'choice' in key]
|
315 |
-
choices = '\n'.join(f"{chr(ord('A') + i)}. {x[choice]}" for i, choice in enumerate(choice_list))
|
316 |
-
question = '\n'.join([x['question'], choices])
|
317 |
-
data.append({'image': f"SEED-Bench/SEED-Bench-image/{x['data_id']}",
|
318 |
-
'question': question,
|
319 |
-
'id': x['question_id'],
|
320 |
-
'question_type': x['question_type_id'],
|
321 |
-
'gt': x['answer']})
|
322 |
-
return data
|
323 |
-
|
324 |
-
def llava_filtering(self, pre_data):
|
325 |
-
data = []
|
326 |
-
for _, x in pre_data.iterrows():
|
327 |
-
data.append({'image': f"llava-bench-in-the-wild/images/{x['image']}",
|
328 |
-
'question': x['text'],
|
329 |
-
'id': x['question_id'],
|
330 |
-
"category": x['category']})
|
331 |
-
return data
|
332 |
-
|
333 |
-
def blink_filtering(self, pre_data):
|
334 |
-
data = []
|
335 |
-
# TODO
|
336 |
-
return data
|
337 |
-
|
338 |
-
def mathverse_filtering(self, pre_data, pre_data_text_only):
|
339 |
-
data = []
|
340 |
-
for x in pre_data:
|
341 |
-
data.append({'image': f"MathVerse/images/{x['image']}",
|
342 |
-
'question': "<image>" + x['query_wo'],
|
343 |
-
# 'question': "<image>" + x['query_cot'],
|
344 |
-
'id': x['sample_index'],
|
345 |
-
'problem_index': x['problem_index'],
|
346 |
-
'problem_version': x['problem_version'],
|
347 |
-
'gt' : x['answer'],
|
348 |
-
'question_type': x['question_type'],
|
349 |
-
'metadata' : x['metadata'],
|
350 |
-
'query_cot' : x['query_cot'],
|
351 |
-
'origin_question': x['question']
|
352 |
-
})
|
353 |
-
offset = len(pre_data)
|
354 |
-
for x in pre_data_text_only:
|
355 |
-
data.append({'image': "",
|
356 |
-
'question': x['query_wo'],
|
357 |
-
# 'question': x['query_cot'],
|
358 |
-
'id': str(int(x['sample_index']) + offset),
|
359 |
-
'problem_index': x['problem_index'],
|
360 |
-
'problem_version': x['problem_version'],
|
361 |
-
'gt' : x['answer'],
|
362 |
-
'question_type': x['question_type'],
|
363 |
-
'metadata' : x['metadata'],
|
364 |
-
'query_cot' : x['query_cot'],
|
365 |
-
'origin_question': x['question']
|
366 |
-
})
|
367 |
-
|
368 |
-
return data
|
369 |
-
|
370 |
-
def is_none(self, value):
|
371 |
-
return type(value) is float and math.isnan(value)
|
372 |
-
|
373 |
-
def get_options(self, row, options):
|
374 |
-
parsed_options = []
|
375 |
-
for option in options:
|
376 |
-
option_value = row[option]
|
377 |
-
if self.is_none(option_value):
|
378 |
-
break
|
379 |
-
parsed_options.append(option_value)
|
380 |
-
return parsed_options
|
381 |
-
|
382 |
-
def __len__(self):
|
383 |
-
return len(self.data)
|
384 |
-
|
385 |
-
def get_multi_choice_info(self, options):
|
386 |
-
"""
|
387 |
-
Given the list of options for multiple choice question
|
388 |
-
Return the index2ans and all_choices
|
389 |
-
"""
|
390 |
-
|
391 |
-
start_chr = 'A'
|
392 |
-
all_choices = []
|
393 |
-
index2ans = {}
|
394 |
-
for i, option in enumerate(options):
|
395 |
-
index2ans[chr(ord(start_chr) + i)] = option
|
396 |
-
all_choices.append(chr(ord(start_chr) + i))
|
397 |
-
|
398 |
-
return index2ans, all_choices
|
399 |
-
|
400 |
-
def mmstar_filtering(self, pre_data):
|
401 |
-
data = []
|
402 |
-
for _, x in pre_data.iterrows():
|
403 |
-
data.append({'id' : x['index'],
|
404 |
-
'question': x['question'],
|
405 |
-
'answer': x['answer'],
|
406 |
-
'category': x['category'],
|
407 |
-
'l2_category': x['l2_category'],
|
408 |
-
# 'bench': x['bench'],
|
409 |
-
'image': x['image']})
|
410 |
-
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils/ddp_accel_bf16.yaml
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
compute_environment: LOCAL_MACHINE
|
2 |
-
debug: false
|
3 |
-
distributed_type: MULTI_GPU
|
4 |
-
downcast_bf16: 'no'
|
5 |
-
gpu_ids: all
|
6 |
-
machine_rank: 0
|
7 |
-
main_training_function: main
|
8 |
-
mixed_precision: no
|
9 |
-
num_machines: 1
|
10 |
-
num_processes: 1
|
11 |
-
rdzv_backend: static
|
12 |
-
same_network: true
|
13 |
-
tpu_env: []
|
14 |
-
tpu_use_cluster: false
|
15 |
-
tpu_use_sudo: false
|
16 |
-
use_cpu: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils/ddp_accel_fp16.yaml
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
compute_environment: LOCAL_MACHINE
|
2 |
-
debug: false
|
3 |
-
distributed_type: MULTI_GPU
|
4 |
-
downcast_bf16: 'no'
|
5 |
-
gpu_ids: all
|
6 |
-
machine_rank: 0
|
7 |
-
main_training_function: main
|
8 |
-
mixed_precision: no
|
9 |
-
num_machines: 1
|
10 |
-
num_processes: 1
|
11 |
-
rdzv_backend: static
|
12 |
-
same_network: true
|
13 |
-
tpu_env: []
|
14 |
-
tpu_use_cluster: false
|
15 |
-
tpu_use_sudo: false
|
16 |
-
use_cpu: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils/ds_accel_fp16.yaml
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
compute_environment: LOCAL_MACHINE
|
2 |
-
debug: false
|
3 |
-
deepspeed_config:
|
4 |
-
gradient_accumulation_steps: 1
|
5 |
-
offload_optimizer_device: none
|
6 |
-
offload_param_device: none
|
7 |
-
zero3_init_flag: false
|
8 |
-
zero3_save_16bit_model: false
|
9 |
-
zero_stage: 3
|
10 |
-
distributed_type: DEEPSPEED
|
11 |
-
downcast_bf16: 'no'
|
12 |
-
enable_cpu_affinity: false
|
13 |
-
machine_rank: 0
|
14 |
-
main_training_function: main
|
15 |
-
mixed_precision: fp16
|
16 |
-
num_machines: 1
|
17 |
-
num_processes: 1
|
18 |
-
rdzv_backend: static
|
19 |
-
same_network: true
|
20 |
-
tpu_env: []
|
21 |
-
tpu_use_cluster: false
|
22 |
-
tpu_use_sudo: false
|
23 |
-
use_cpu: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|