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

Adding Gaussian Blur as 'hide_color' option #533

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
8 changes: 7 additions & 1 deletion lime/lime_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from . import lime_base
from .wrappers.scikit_image import SegmentationAlgorithm

from skimage.filters import gaussian

class ImageExplanation(object):
def __init__(self, image, segments):
Expand Down Expand Up @@ -186,12 +187,17 @@ def explain_instance(self, image, classifier_fn, labels=(1,),
raise e

fudged_image = image.copy()
if hide_color is None:

if hide_color is 'blur':
fudged_image = gaussian(fudged_image, sigma=4, multichannel=True, preserve_range = True)

elif hide_color is None:
for x in np.unique(segments):
fudged_image[segments == x] = (
np.mean(image[segments == x][:, 0]),
np.mean(image[segments == x][:, 1]),
np.mean(image[segments == x][:, 2]))

else:
fudged_image[:] = hide_color

Expand Down