From e2cf67fb3237ce480d93fabaaf5af8ab8e22d4a2 Mon Sep 17 00:00:00 2001 From: ZiniuYu Date: Wed, 31 Aug 2022 10:42:01 +0800 Subject: [PATCH 1/3] chore: update model not found error msg in torch runtime --- server/clip_server/model/clip_model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/clip_server/model/clip_model.py b/server/clip_server/model/clip_model.py index fc8a9dd01..6db7e470d 100644 --- a/server/clip_server/model/clip_model.py +++ b/server/clip_server/model/clip_model.py @@ -35,7 +35,9 @@ def __new__(cls, name: str, **kwargs): instance = super().__new__(MultilingualCLIPModel) else: - raise ValueError(f'The CLIP model name=`{name}` is not supported.') + raise ValueError( + f'Model {name} not found; available models = {list(_OPENCLIP_MODELS.keys()) + list(_MULTILINGUALCLIP_MODELS.keys())} ' + ) else: instance = super().__new__(cls) return instance From ac56ae5467e588d474eb9bc91fa84b5f18f95a97 Mon Sep 17 00:00:00 2001 From: ZiniuYu Date: Wed, 31 Aug 2022 13:52:27 +0800 Subject: [PATCH 2/3] chore: reformat error msg --- server/clip_server/model/clip_model.py | 11 ++++++++++- server/clip_server/model/clip_onnx.py | 5 ++++- server/clip_server/model/clip_trt.py | 11 ++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/server/clip_server/model/clip_model.py b/server/clip_server/model/clip_model.py index 6db7e470d..7164cfea8 100644 --- a/server/clip_server/model/clip_model.py +++ b/server/clip_server/model/clip_model.py @@ -36,7 +36,16 @@ def __new__(cls, name: str, **kwargs): instance = super().__new__(MultilingualCLIPModel) else: raise ValueError( - f'Model {name} not found; available models = {list(_OPENCLIP_MODELS.keys()) + list(_MULTILINGUALCLIP_MODELS.keys())} ' + 'CLIP model {} not found; below is a list of all available models:\n{}'.format( + name, + ''.join( + [ + '\t- {}\n'.format(i) + for i in list(_OPENCLIP_MODELS.keys()) + + list(_MULTILINGUALCLIP_MODELS.keys()) + ] + ), + ) ) else: instance = super().__new__(cls) diff --git a/server/clip_server/model/clip_onnx.py b/server/clip_server/model/clip_onnx.py index 980e71b52..cf82f9100 100644 --- a/server/clip_server/model/clip_onnx.py +++ b/server/clip_server/model/clip_onnx.py @@ -193,7 +193,10 @@ def __init__(self, name: str, model_path: str = None): ) else: raise RuntimeError( - f'Model {name} not found; available models = {list(_MODELS.keys())}' + 'CLIP model {} not found or not supports ONNX backend; below is a list of all available models:\n{}'.format( + name, + ''.join(['\t- {}\n'.format(i) for i in list(_MODELS.keys())]), + ) ) @staticmethod diff --git a/server/clip_server/model/clip_trt.py b/server/clip_server/model/clip_trt.py index b43a20c5b..1d094df3b 100644 --- a/server/clip_server/model/clip_trt.py +++ b/server/clip_server/model/clip_trt.py @@ -114,7 +114,16 @@ def __init__( save_engine(text_engine, self._textual_path) else: raise RuntimeError( - f'Model {name} not found or not supports Nvidia TensorRT backend; available models = {list(_MODELS.keys())}' + 'CLIP model {} not found or not supports Nvidia TensorRT backend; below is a list of all available models:\n{}'.format( + name, + ''.join( + [ + '\t- {}\n'.format(i) + for i in list(_OPENCLIP_MODELS.keys()) + + list(_MULTILINGUALCLIP_MODELS.keys()) + ] + ), + ) ) @staticmethod From 78a75a71342ef62204e9fa00a328fefd32f8062a Mon Sep 17 00:00:00 2001 From: ZiniuYu Date: Wed, 31 Aug 2022 13:59:28 +0800 Subject: [PATCH 3/3] fix: typo --- server/clip_server/model/clip_trt.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/server/clip_server/model/clip_trt.py b/server/clip_server/model/clip_trt.py index 1d094df3b..1510003c5 100644 --- a/server/clip_server/model/clip_trt.py +++ b/server/clip_server/model/clip_trt.py @@ -116,13 +116,7 @@ def __init__( raise RuntimeError( 'CLIP model {} not found or not supports Nvidia TensorRT backend; below is a list of all available models:\n{}'.format( name, - ''.join( - [ - '\t- {}\n'.format(i) - for i in list(_OPENCLIP_MODELS.keys()) - + list(_MULTILINGUALCLIP_MODELS.keys()) - ] - ), + ''.join(['\t- {}\n'.format(i) for i in list(_MODELS.keys())]), ) )