Skip to content

Commit

Permalink
fix: openclip compatable
Browse files Browse the repository at this point in the history
  • Loading branch information
numb3r3 committed Jul 26, 2022
1 parent ab23235 commit 0ba7fad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions server/clip_server/model/openclip_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
from open_clip.model import (
CLIP,
convert_weights_to_fp16,
build_model_from_openai_state_dict,
)
from open_clip.factory import _MODEL_CONFIGS, load_checkpoint, load_openai_model
from open_clip.factory import _MODEL_CONFIGS, load_state_dict, load_openai_model

if TYPE_CHECKING:
import torch
Expand Down Expand Up @@ -48,7 +47,8 @@ def __init__(self, name: str, device: str = 'cpu', jit: bool = False, **kwargs):

self._model = CLIP(**model_cfg)

load_checkpoint(self._model, model_path)
state_dict = load_state_dict(model_path)
self._model.load_state_dict(state_dict, strict=True)

if str(device) == 'cuda':
convert_weights_to_fp16(self._model)
Expand Down
2 changes: 1 addition & 1 deletion server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
'torchvision',
'jina>=3.6.0',
'prometheus-client',
'open_clip_torch',
'open_clip_torch>=1.3.0',
],
extras_require={
'onnx': [
Expand Down

0 comments on commit 0ba7fad

Please sign in to comment.