Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
numb3r3 committed Jun 1, 2022
1 parent 3dce99d commit ef11565
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions server/clip_server/executors/clip_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions server/clip_server/executors/clip_tensorrt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions server/clip_server/executors/clip_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit ef11565

Please sign in to comment.