marcotcr / lime

Lime: Explaining the predictions of any machine learning classifier
BSD 2-Clause "Simplified" License
11.64k stars 1.81k forks source link

NameError: name 'qs_kernel_size' is not defined #672

Open Lilithrrm opened 2 years ago

Lilithrrm commented 2 years ago

Hi all,

my image z is of size (128, 128, 1). Since my model only takes image(s) of shape (x,128,128,1), I modified the 'lime_image.py' accordingly to #116.

When I hit

explanation = explainer.explain_instance(z, model.predict, top_labels=5, hide_color=None,num_samples=1000)

I get

NameError                                 Traceback (most recent call last)
<ipython-input-18-1b04fb1bf0f7> in <module>
----> 1 explanation = explainer.explain_instance(z, model.predict, top_labels=5, hide_color=None,num_samples=1000)

~/.local/lib/python3.7/site-packages/lime-0.2.0.1-py3.7.egg/lime/lime_image.py in explain_instance(self, image, classifier_fn, labels, hide_color, top_labels, num_features, num_samples, batch_size, segmentation_fn, distance_metric, model_regressor, random_seed, progress_bar)
    185             qs_image = image
    186 
--> 187         segments = quickshift(qs_image, kernel_size=qs_kernel_size,
    188                               max_dist=200, ratio=0.2, random_seed=random_seed)
    189         #segments = segmentation_fn(image)

**NameError: name 'qs_kernel_size' is not defined**

And as I see, 'qs_kernel_size' is really never being defined within 'lime_image.py'. (No matter if you modify the code for accepting grayscale images or not.)

Thanks in advance for your help!