From 21a906accae208779a16d4d0fb7b7bf5b54f4fbb Mon Sep 17 00:00:00 2001 From: Bo Li Date: Sun, 22 Sep 2024 14:28:39 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improve=20model=20name=20sanitizati?= =?UTF-8?q?on=20for=20Hugging=20Face=20formats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lmms_eval/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lmms_eval/utils.py b/lmms_eval/utils.py index d9452a40..c2a8c536 100755 --- a/lmms_eval/utils.py +++ b/lmms_eval/utils.py @@ -246,7 +246,9 @@ def sanitize_model_name(model_name: str, full_path: bool = False) -> str: if full_path: return re.sub(r"[\"<>:/\|\\?\*\[\]]+", "__", model_name) else: - return re.sub(r"[\"<>:/\|\\?\*\[\]]+", "__", model_name.split("/")[-1]) + parts = model_name.split("/") + last_two = "/".join(parts[-2:]) if len(parts) > 1 else parts[-1] # accommondate for models that are in Hugging Face Hub format like lmms-lab/llava-onevision-qwen2-0.5b + return re.sub(r"[\"<>:/\|\\?\*\[\]]+", "__", last_two) def sanitize_task_name(task_name: str) -> str: