1+ import argparse
2+ import copy as cp
3+ import datetime
14import json
25import os
6+ import os .path as osp
37import subprocess
48from functools import partial
59
10+ import pandas as pd
11+ from tabulate import tabulate
12+
613
714# GET the number of GPUs on the node without importing libs like torch
815def get_gpu_list ():
@@ -14,14 +21,14 @@ def get_gpu_list():
1421 ps = subprocess .Popen (('nvidia-smi' , '--list-gpus' ), stdout = subprocess .PIPE )
1522 output = subprocess .check_output (('wc' , '-l' ), stdin = ps .stdout )
1623 return list (range (int (output )))
17- except :
24+ except Exception :
1825 return []
1926
2027
2128RANK = int (os .environ .get ('RANK' , 0 ))
2229WORLD_SIZE = int (os .environ .get ('WORLD_SIZE' , 1 ))
23- LOCAL_WORLD_SIZE = int (os .environ .get ("LOCAL_WORLD_SIZE" ,1 ))
24- LOCAL_RANK = int (os .environ .get ("LOCAL_RANK" ,1 ))
30+ LOCAL_WORLD_SIZE = int (os .environ .get ("LOCAL_WORLD_SIZE" , 1 ))
31+ LOCAL_RANK = int (os .environ .get ("LOCAL_RANK" , 1 ))
2532
2633GPU_LIST = get_gpu_list ()
2734if LOCAL_WORLD_SIZE > 1 and len (GPU_LIST ):
@@ -40,12 +47,13 @@ def get_gpu_list():
4047
4148
4249from vlmeval .config import supported_VLM
43- from vlmeval .dataset .video_dataset_config import supported_video_datasets
4450from vlmeval .dataset import build_dataset
51+ from vlmeval .dataset .video_dataset_config import supported_video_datasets
4552from vlmeval .inference import infer_data_job
46- from vlmeval .inference_video import infer_data_job_video
4753from vlmeval .inference_mt import infer_data_job_mt
48- from vlmeval .smp import *
54+ from vlmeval .inference_video import infer_data_job_video
55+ from vlmeval .smp import (MMBenchOfficialServer , get_pred_file_format , githash , listinstr , load ,
56+ load_env , ls , prepare_reuse_files , proxy_set , setup_logger , timestr )
4957from vlmeval .utils .result_transfer import MMMU_result_transfer , MMTBench_result_transfer
5058
5159
@@ -74,8 +82,9 @@ def build_model_from_config(cfg, model_name, use_vllm=False):
7482
7583
7684def build_dataset_from_config (cfg , dataset_name ):
77- import vlmeval .dataset
7885 import inspect
86+
87+ import vlmeval .dataset
7988 config = cp .deepcopy (cfg [dataset_name ])
8089 if config == {}:
8190 return supported_video_datasets [dataset_name ]()
@@ -201,7 +210,6 @@ def parse_args():
201210
202211
203212def main ():
204- logger = get_logger ('RUN' )
205213 args = parse_args ()
206214 use_config , cfg = False , None
207215 if args .config is not None :
@@ -212,15 +220,19 @@ def main():
212220 else :
213221 assert len (args .data ), '--data should be a list of data files'
214222
223+ if 'MMEVAL_ROOT' in os .environ :
224+ args .work_dir = os .environ ['MMEVAL_ROOT' ]
225+
226+ date , commit_id = timestr ('day' ), githash (digits = 8 )
227+ eval_id = f"T{ date } _G{ commit_id } "
228+ logger = setup_logger (log_file = os .path .join (args .work_dir , 'logs' , f'{ eval_id } _{ timestr ()} .log' ))
229+
215230 if RANK == 0 :
216231 if not args .reuse :
217232 logger .warning ('--reuse is not set, will not reuse previous (before one day) temporary files' )
218233 else :
219234 logger .warning ('--reuse is set, will reuse the latest prediction & temporary pickle files' )
220235
221- if 'MMEVAL_ROOT' in os .environ :
222- args .work_dir = os .environ ['MMEVAL_ROOT' ]
223-
224236 if not use_config :
225237 for k , v in supported_VLM .items ():
226238 if hasattr (v , 'keywords' ) and 'retry' in v .keywords and args .retry is not None :
@@ -232,8 +244,8 @@ def main():
232244
233245 # If FWD_API is set, will use class `GPT4V` for all API models in the config
234246 if os .environ .get ('FWD_API' , None ) == '1' :
235- from vlmeval .config import api_models as supported_APIs
236247 from vlmeval .api import GPT4V
248+ from vlmeval .config import api_models as supported_APIs
237249 for m in args .model :
238250 if m in supported_APIs :
239251 kws = supported_VLM [m ].keywords
@@ -248,6 +260,7 @@ def main():
248260 )
249261
250262 for _ , model_name in enumerate (args .model ):
263+ logger .info (f'=========== { model_name } ===========' )
251264 model = None
252265 date , commit_id = timestr ('day' ), githash (digits = 8 )
253266 eval_id = f"T{ date } _G{ commit_id } "
@@ -267,6 +280,7 @@ def main():
267280 model = build_model_from_config (cfg ['model' ], model_name , args .use_vllm )
268281
269282 for _ , dataset_name in enumerate (args .data ):
283+ logger .info (f'----------- { dataset_name } -----------' )
270284 if WORLD_SIZE > 1 :
271285 dist .barrier ()
272286
0 commit comments