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

Keras image explainer not working #18

Closed
mv96 opened this issue Apr 8, 2022 · 2 comments
Closed

Keras image explainer not working #18

mv96 opened this issue Apr 8, 2022 · 2 comments

Comments

@mv96
Copy link

mv96 commented Apr 8, 2022

OS: macOS Monterey v12.2.1
Hardware: MacBook Pro (13-inch, M1, 2020)
Chip: Apple M1
Python 3.9.10

AttributeError Traceback (most recent call last)
Input In [22], in
10 warnings.simplefilter("ignore") # disable Keras warnings for this tutorial
11 import keras
---> 14 import eli5

File ~/miniforge3/envs/tf_gpu/lib/python3.9/site-packages/eli5/init.py:6, in
2 from future import absolute_import
4 version = '0.11.0'
----> 6 from .formatters import (
7 format_as_html,
8 format_html_styles,
9 format_as_text,
10 format_as_dict,
11 )
12 from .explain import explain_weights, explain_prediction
13 from .sklearn import explain_weights_sklearn, explain_prediction_sklearn

File ~/miniforge3/envs/tf_gpu/lib/python3.9/site-packages/eli5/formatters/init.py:9, in
2 """
3 Functions to convert explanations to human-digestible formats.
4
5 TODO: IPython integration, customizability.
6 """
8 from .text import format_as_text
----> 9 from .html import format_as_html, format_html_styles
10 try:
11 from .as_dataframe import (
12 explain_weights_df, explain_weights_dfs,
13 explain_prediction_df, explain_prediction_dfs,
14 format_as_dataframe, format_as_dataframes,
15 )

File ~/miniforge3/envs/tf_gpu/lib/python3.9/site-packages/eli5/formatters/html.py:22, in
18 from .trees import tree2text
19 from .text_helpers import prepare_weighted_spans, PreparedWeightedSpans
---> 22 template_env = Environment(
23 loader=PackageLoader('eli5', 'templates'),
24 extensions=['jinja2.ext.with_'])
25 template_env.globals.update(dict(zip=zip, numpy=np))
26 template_env.filters.update(dict(
27 weight_color=lambda w, w_range: format_hsl(weight_color_hsl(w, w_range)),
28 remaining_weight_color=lambda ws, w_range, pos_neg:
(...)
33 format_decision_tree=lambda tree: _format_decision_tree(tree),
34 ))

File ~/miniforge3/envs/tf_gpu/lib/python3.9/site-packages/jinja2/environment.py:363, in Environment.init(self, block_start_string, block_end_string, variable_start_string, variable_end_string, comment_start_string, comment_end_string, line_statement_prefix, line_comment_prefix, trim_blocks, lstrip_blocks, newline_sequence, keep_trailing_newline, extensions, optimized, undefined, finalize, autoescape, loader, cache_size, auto_reload, bytecode_cache, enable_async)
360 self.policies = DEFAULT_POLICIES.copy()
362 # load extensions
--> 363 self.extensions = load_extensions(self, extensions)
365 self.is_async = enable_async
366 _environment_config_check(self)

File ~/miniforge3/envs/tf_gpu/lib/python3.9/site-packages/jinja2/environment.py:117, in load_extensions(environment, extensions)
115 for extension in extensions:
116 if isinstance(extension, str):
--> 117 extension = t.cast(t.Type["Extension"], import_string(extension))
119 result[extension.identifier] = extension(environment)
121 return result

File ~/miniforge3/envs/tf_gpu/lib/python3.9/site-packages/jinja2/utils.py:149, in import_string(import_name, silent)
147 else:
148 return import(import_name)
--> 149 return getattr(import(module, None, None, [obj]), obj)
150 except (ImportError, AttributeError):
151 if not silent:

AttributeError: module 'jinja2.ext' has no attribute 'with_'

@amaiya
Copy link

amaiya commented May 16, 2022

pip install jinja2==3.0.3 should solve this.

@lopuhin
Copy link
Contributor

lopuhin commented May 17, 2022

Right, it should be resolved in master and in latest release

@lopuhin lopuhin closed this as completed May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants