modelscope: fix issue when model parameter is not a model id but path of the model. (#2489)

This commit is contained in:
liuyhwangyh 2024-02-07 01:57:15 +08:00 committed by GitHub
parent f0d4e14557
commit ed70c70ea3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,9 +93,12 @@ class ModelConfig:
# download model from ModelScope hub,
# lazy import so that modelscope is not required for normal use.
from modelscope.hub.snapshot_download import snapshot_download # pylint: disable=C
model_path = snapshot_download(model_id=model,
cache_dir=download_dir,
revision=revision)
if not os.path.exists(model):
model_path = snapshot_download(model_id=model,
cache_dir=download_dir,
revision=revision)
else:
model_path = model
self.model = model_path
self.download_dir = model_path
self.tokenizer = model_path