Skip to content

Commit

Permalink
fix: apply comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiniuYu committed Sep 23, 2022
1 parent d9fa266 commit 4b754e3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions server/clip_server/model/clip_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def start_sessions(
):
import onnxruntime as ort

def load_zip_model(model_path, model_type):
def _load_session_from_zip(model_path: str, model_type: str):
"""Load a model from a zip file."""
import zipfile
import tempfile
Expand All @@ -276,13 +276,15 @@ def load_zip_model(model_path, model_type):
return ort.InferenceSession(tmp_dir + f'/{model_type}.onnx', **kwargs)

if self._visual_path.endswith('.zip'):
self._visual_session = load_zip_model(self._visual_path, 'visual')
self._visual_session = _load_session_from_zip(self._visual_path, 'visual')
else:
self._visual_session = ort.InferenceSession(self._visual_path, **kwargs)
self._visual_session.disable_fallback()

if self._textual_path.endswith('.zip'):
self._textual_session = load_zip_model(self._textual_path, 'textual')
self._textual_session = _load_session_from_zip(
self._textual_path, 'textual'
)
else:
self._textual_session = ort.InferenceSession(self._textual_path, **kwargs)
self._textual_session.disable_fallback()
Expand Down

0 comments on commit 4b754e3

Please sign in to comment.