Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set x_ref_preprocessed=True during legacy loading (v0.10.5 patch) #732

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions alibi_detect/saving/tensorflow/_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ def load_detector_legacy(filepath: Union[str, os.PathLike], suffix: str, **kwarg
# load outlier detector specific parameters
state_dict = dill.load(open(filepath.joinpath(detector_name + suffix), 'rb'))

# Update the drift detector preprocess kwargs if state_dict is from an old alibi-detect version (<v0.10).
# See https://github.com/SeldonIO/alibi-detect/pull/732
if 'kwargs' in state_dict and 'other' in state_dict: # A drift detector if both of these exist
if 'x_ref_preprocessed' not in state_dict['kwargs']: # if already exists then must have been saved w/ >=v0.10
# Set x_ref_preprocessed to True
state_dict['kwargs']['x_ref_preprocessed'] = True
# Move `preprocess_x_ref` from `other` to `kwargs`
state_dict['kwargs']['preprocess_x_ref'] = state_dict['other']['preprocess_x_ref']

# initialize detector
model_dir = filepath.joinpath('model')
detector: Optional[Detector] = None # to avoid mypy errors
Expand Down