I am implementing LIME on my resnet50 mode. There are 4 classes in the dataset. the code snippet of LIME:

img = cv2.imread('/content/drive/MyDrive/Dataset/cat/cat129.png')
img = cv2.resize(img, (224,224))
img = image.img_to_array(img)
img = np.expand_dims(img, axis=0)

import lime
from lime import lime_image

explainer = lime_image.LimeImageExplainer()


explanation = explainer.explain_instance(img[0].astype('double'), model.predict,  
                                         top_labels=3, hide_color=0, num_samples=1000)
from skimage.segmentation import mark_boundaries

temp_1, mask_1 = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=True ,negative_only=False, num_features=5, hide_rest=True)
temp_2, mask_2 = explanation.get_image_and_mask(explanation.top_labels[0], positive_only=False ,negative_only=True, num_features=10, hide_rest=False)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15,15))
ax1.imshow(mark_boundaries(temp_1, mask_1))
ax2.imshow(mark_boundaries(temp_2, mask_2))

The output I expecting was something like this: enter image description here

But the output I'm getting is something like this: enter image description here

I want to know how can achieve this, which line of code should I modify?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.