from .utils import log import re def evaluate(verbose, llm, zip, readme): log(verbose, "TITLE", "\nLooking for examples for running the model...") overall = "No" patterns = { 'tensorflow': [ r'tf\.keras\.models\.load_model', # TensorFlow model loading r'tf\.saved_model\.load', r'\.predict', # Running inference ], 'pytorch': [ r'torch\.load', # PyTorch model loading r'torch\.jit\.load', # PyTorch JIT model loading r'\.eval', # Running inference ] } files = [file_path for file_path in zip.namelist() if ((file_path.endswith(".py") | file_path.endswith(".ipynb")))] for file_path in files: code = zip.open(file_path).read().decode("utf-8") for framework, regex_list in patterns.items(): for pattern in regex_list: if re.search(pattern, code): log(verbose, "LOG", f"Found code for evaluating a model in {framework} framework in file: {file_path}") overall = "Yes" if (readme): if ((len(re.findall("testing", readme)) > 0)): log(verbose, "LOG", "Found information about evaluations in readme") overall = "Yes" if (overall == "No"): log(verbose, "ERROR", "Found no code for evaluating the model.") return overall