Skip to content

Commit

Permalink
avoid failure of plot_feature_outlier_image
Browse files Browse the repository at this point in the history
I call the function this way:
plot_feature_outlier_image(preds,  # output of an prediction
                                   ds, # my set of images
                                   X_recon=recon, # reconstructed set of images
                                   max_instances=5,       # max nb of instances to display
                                   n_channels=3,          # number of channels of the images
                                   figsize=(20,10),
                                   outliers_only=True)    # only show outlier predictions. this function fails when no outlier is detected and parameter set to True
In case there is no outlieres detected and the parameter outliers_only is set to True, then the function fails, because it calls plt.subplots(nrows=0, ....). 0 rows throws the error.
  • Loading branch information
signupatgmx committed Apr 19, 2023
1 parent 3992180 commit dc0eb26
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions alibi_detect/utils/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def plot_feature_outlier_image(od_preds: Dict,
instance_ids = list(range(len(od_preds['data']['is_outlier'])))
n_instances = min(max_instances, len(instance_ids))
instance_ids = instance_ids[:n_instances]

if outliers_only and n_instances == 0:
return

n_cols = 2

if n_channels == 3:
Expand Down

0 comments on commit dc0eb26

Please sign in to comment.