@@ -160,37 +160,7 @@ def __init__(self, *args, **kwargs):
160
160
self .add_argument ("--to_quant_block_names" , default = None , type = str ,
161
161
help = "Names of quantitative blocks, please use commas to separate them." )
162
162
163
- ## ======================= VLM eval=======================
164
- self .add_argument ("--tasks" , type = str ,
165
- default = "MMBench_DEV_EN_V11,ScienceQA_VAL,TextVQA_VAL,POPE" ,
166
- help = "eval tasks for VLMEvalKit." )
167
- # Args that only apply to Video Dataset
168
- self .add_argument ("--nframe" , type = int , default = 8 ,
169
- help = "the number of frames to sample from a video,"
170
- " only applicable to the evaluation of video benchmarks." )
171
- self .add_argument ("--pack" , action = 'store_true' ,
172
- help = "a video may associate with multiple questions, if pack==True,"
173
- " will ask all questions for a video in a single" )
174
- self .add_argument ("--use-subtitle" , action = 'store_true' )
175
- self .add_argument ("--fps" , type = float , default = - 1 )
176
- # Work Dir
177
- # Infer + Eval or Infer Only
178
- self .add_argument ("--mode" , type = str , default = 'all' , choices = ['all' , 'infer' ],
179
- help = "when mode set to 'all', will perform both inference and evaluation;"
180
- " when set to 'infer' will only perform the inference." )
181
- self .add_argument ('--eval_data_dir' , type = str , default = None ,
182
- help = 'path for VLMEvalKit to store the eval data. Default will store in ~/LMUData' )
183
- # API Kwargs, Apply to API VLMs and Judge API LLMs
184
- self .add_argument ('--retry' , type = int , default = None , help = 'retry numbers for API VLMs' )
185
- # Explicitly Set the Judge Model
186
- self .add_argument ('--judge' , type = str , default = None )
187
- # Logging Utils
188
- self .add_argument ('--verbose' , action = 'store_true' )
189
- # Configuration for Resume
190
- # Ignore: will not rerun failed VLM inference
191
- self .add_argument ('--ignore' , action = 'store_true' , help = 'ignore failed indices. ' )
192
- # Rerun: will remove all evaluation temp files
193
- self .add_argument ('--rerun' , action = 'store_true' )
163
+
194
164
195
165
196
166
def setup_parser ():
@@ -215,6 +185,50 @@ def setup_parser():
215
185
return args
216
186
217
187
188
+ def setup_lmeval_parser ():
189
+ parser = argparse .ArgumentParser ()
190
+ parser .add_argument ("--model" , "--model_name" , "--model_name_or_path" ,
191
+ help = "model name or path" )
192
+ parser .add_argument ("--tasks" , type = str ,
193
+ default = "MMBench_DEV_EN_V11,ScienceQA_VAL,TextVQA_VAL,POPE" ,
194
+ help = "eval tasks for VLMEvalKit." )
195
+ # Args that only apply to Video Dataset
196
+ parser .add_argument ("--nframe" , type = int , default = 8 ,
197
+ help = "the number of frames to sample from a video,"
198
+ " only applicable to the evaluation of video benchmarks." )
199
+ parser .add_argument ("--pack" , action = 'store_true' ,
200
+ help = "a video may associate with multiple questions, if pack==True,"
201
+ " will ask all questions for a video in a single" )
202
+ parser .add_argument ("--fps" , type = float , default = - 1 ,
203
+ help = "set the fps for a video." )
204
+ # Work Dir
205
+ # Infer + Eval or Infer Only
206
+ parser .add_argument ("--mode" , type = str , default = 'all' , choices = ['all' , 'infer' ],
207
+ help = "when mode set to 'all', will perform both inference and evaluation;"
208
+ " when set to 'infer' will only perform the inference." )
209
+ parser .add_argument ('--eval_data_dir' , type = str , default = None ,
210
+ help = 'path for VLMEvalKit to store the eval data. Default will store in ~/LMUData' )
211
+ # API Kwargs, Apply to API VLMs and Judge API LLMs
212
+ parser .add_argument ('--retry' , type = int , default = None , help = 'retry numbers for API VLMs' )
213
+ # Explicitly Set the Judge Model
214
+ parser .add_argument ('--judge' , type = str , default = None ,
215
+ help = "whether is a judge model." )
216
+ # Logging Utils
217
+ parser .add_argument ('--verbose' , action = 'store_true' ,
218
+ help = "whether to display verbose information." )
219
+ # Configuration for Resume
220
+ # Ignore: will not rerun failed VLM inference
221
+ parser .add_argument ('--ignore' , action = 'store_true' ,
222
+ help = 'ignore failed indices. ' )
223
+ # Rerun: will remove all evaluation temp files
224
+ parser .add_argument ('--rerun' , action = 'store_true' ,
225
+ help = "if true, will remove all evaluation temp files and rerun." )
226
+ parser .add_argument ("--output_dir" , default = "./eval_result" , type = str ,
227
+ help = "the directory to save quantized model" )
228
+ args = parser .parse_args ()
229
+ return args
230
+
231
+
218
232
def tune (args ):
219
233
if args .format is None :
220
234
args .format = "auto_round"
@@ -265,14 +279,14 @@ def tune(args):
265
279
processor , image_processor = None , None
266
280
if "llava" in model_name :
267
281
from llava .model .builder import load_pretrained_model # pylint: disable=E0401
268
- tokenizer , model , image_processor , _ = load_pretrained_model (model_name , model_base = None , model_name = model_name ,
269
- torch_dtype = torch_dtype )
282
+ tokenizer , model , image_processor , _ = load_pretrained_model (
283
+ model_name , model_base = None , model_name = model_name ,
284
+ torch_dtype = torch_dtype )
270
285
model_type = "llava"
271
286
else :
272
287
config = AutoConfig .from_pretrained (model_name , trust_remote_code = not args .disable_trust_remote_code )
273
288
tokenizer = AutoTokenizer .from_pretrained (model_name )
274
289
processor = AutoProcessor .from_pretrained (model_name , trust_remote_code = not args .disable_trust_remote_code )
275
- tokenizer .processor = processor
276
290
model_type = config .model_type
277
291
if "qwen2_vl" in model_type :
278
292
from transformers import Qwen2VLForConditionalGeneration
@@ -361,7 +375,7 @@ def tune(args):
361
375
if "--truncation" not in sys .argv :
362
376
args .truncation = None
363
377
364
- autoround = round (model , tokenizer , image_processor = image_processor , dataset = args .dataset ,
378
+ autoround = round (model , tokenizer , processor = processor , image_processor = image_processor , dataset = args .dataset ,
365
379
extra_data_dir = args .extra_data_dir , bits = args .bits , group_size = args .group_size ,
366
380
sym = not args .asym , batch_size = args .batch_size , seqlen = seqlen , nblocks = args .nblocks ,
367
381
iters = args .iters , lr = args .lr , minmax_lr = args .minmax_lr , amp = not args .disable_amp ,
@@ -406,7 +420,6 @@ def eval(args):
406
420
data_store_dir = args .eval_data_dir ,
407
421
dataset = args .tasks ,
408
422
pack = args .pack ,
409
- use_subtitle = args .use_subtitle ,
410
423
fps = args .fps ,
411
424
nframe = args .nframe ,
412
425
rerun = args .rerun ,
@@ -426,8 +439,8 @@ def setup_lmms_parser():
426
439
default = "pope,textvqa_val,scienceqa,mmbench_en" ,
427
440
help = "To get full list of tasks, use the command lmms-eval --tasks list" ,
428
441
)
429
- parser .add_argument ("--output_dir" , default = "./tmp_autoround " , type = str ,
430
- help = "the directory to save quantized model" )
442
+ parser .add_argument ("--output_dir" , default = "./eval_result " , type = str ,
443
+ help = "the directory to save quantized model" )
431
444
parser .add_argument (
432
445
"--num_fewshot" ,
433
446
type = int ,
0 commit comments