From ef115659b7f5c9e70ea28192e82bc35218d88d08 Mon Sep 17 00:00:00 2001 From: numb3r3 Date: Wed, 1 Jun 2022 15:44:52 +0800 Subject: [PATCH] fix: address comments --- server/clip_server/executors/clip_onnx.py | 8 ++++---- server/clip_server/executors/clip_tensorrt.py | 8 ++++---- server/clip_server/executors/clip_torch.py | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/server/clip_server/executors/clip_onnx.py b/server/clip_server/executors/clip_onnx.py index a6a365a74..6afaef9c0 100644 --- a/server/clip_server/executors/clip_onnx.py +++ b/server/clip_server/executors/clip_onnx.py @@ -78,21 +78,21 @@ def __init__( self._model.start_sessions(sess_options=sess_options, providers=providers) - @monitor(name='preprocess_images') + @monitor(name='preprocess_images_seconds') def _preproc_images(self, docs: 'DocumentArray'): return preproc_image( docs, preprocess_fn=self._preprocess_tensor, return_np=True ) - @monitor(name='preprocess_texts') + @monitor(name='preprocess_texts_seconds') def _preproc_texts(self, docs: 'DocumentArray'): return preproc_text(docs, return_np=True) - @monitor(name='encode_images') + @monitor(name='encode_images_seconds') def _encode_images(self, docs: 'DocumentArray'): docs.embeddings = self._model.encode_image(docs.tensors) - @monitor(name='encode_texts') + @monitor(name='encode_texts_seconds') def _encode_texts(self, docs: 'DocumentArray'): docs.embeddings = self._model.encode_text(docs.tensors) diff --git a/server/clip_server/executors/clip_tensorrt.py b/server/clip_server/executors/clip_tensorrt.py index b424fc93e..a05df304a 100644 --- a/server/clip_server/executors/clip_tensorrt.py +++ b/server/clip_server/executors/clip_tensorrt.py @@ -46,7 +46,7 @@ def __init__( self._model.start_engines() - @monitor(name='preprocess_images') + @monitor(name='preprocess_images_seconds') def _preproc_images(self, docs: 'DocumentArray'): return preproc_image( docs, @@ -55,11 +55,11 @@ def _preproc_images(self, docs: 'DocumentArray'): return_np=False, ) - @monitor(name='preprocess_texts') + @monitor(name='preprocess_texts_seconds') def _preproc_texts(self, docs: 'DocumentArray'): return preproc_text(docs, device=self._device, return_np=False) - @monitor(name='encode_images') + @monitor(name='encode_images_seconds') def _encode_images(self, docs: 'DocumentArray'): docs.embeddings = ( self._model.encode_image(docs.tensors) @@ -69,7 +69,7 @@ def _encode_images(self, docs: 'DocumentArray'): .astype(np.float32) ) - @monitor(name='encode_texts') + @monitor(name='encode_texts_seconds') def _encode_texts(self, docs: 'DocumentArray'): docs.embeddings = ( self._model.encode_text(docs.tensors) diff --git a/server/clip_server/executors/clip_torch.py b/server/clip_server/executors/clip_torch.py index 1cbe268dd..2648efa32 100644 --- a/server/clip_server/executors/clip_torch.py +++ b/server/clip_server/executors/clip_torch.py @@ -59,7 +59,7 @@ def __init__( self._pool = ThreadPool(processes=num_worker_preprocess) - @monitor(name='preprocess_images') + @monitor(name='preprocess_images_seconds') def _preproc_images(self, docs: 'DocumentArray'): return preproc_image( docs, @@ -68,17 +68,17 @@ def _preproc_images(self, docs: 'DocumentArray'): return_np=False, ) - @monitor(name='preprocess_texts') + @monitor(name='preprocess_texts_seconds') def _preproc_texts(self, docs: 'DocumentArray'): return preproc_text(docs, device=self._device, return_np=False) - @monitor(name='encode_images') + @monitor(name='encode_images_seconds') def _encode_images(self, docs: 'DocumentArray'): docs.embeddings = ( self._model.encode_image(docs.tensors).cpu().numpy().astype(np.float32) ) - @monitor(name='encode_texts') + @monitor(name='encode_texts_seconds') def _encode_texts(self, docs: 'DocumentArray'): docs.embeddings = ( self._model.encode_text(docs.tensors).cpu().numpy().astype(np.float32)