Spaces:
Sleeping
Sleeping
File size: 1,332 Bytes
77f290b 69cbe77 77f290b 6e3c928 77f290b 6e3c928 77f290b febd197 77f290b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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 |