|
@@ -23,6 +23,13 @@ from .core.interpretation import Interpretation
|
|
|
from .core.normlime_base import precompute_normlime_weights
|
|
from .core.normlime_base import precompute_normlime_weights
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def gen_user_home():
|
|
|
|
|
+ if "HOME" in os.environ:
|
|
|
|
|
+ home_path = os.environ["HOME"]
|
|
|
|
|
+ if os.path.exists(home_path) and os.path.isdir(home_path):
|
|
|
|
|
+ return home_path
|
|
|
|
|
+ return os.path.expanduser('~')
|
|
|
|
|
+
|
|
|
def visualize(img_file,
|
|
def visualize(img_file,
|
|
|
model,
|
|
model,
|
|
|
dataset=None,
|
|
dataset=None,
|
|
@@ -109,7 +116,7 @@ def get_normlime_interpreter(img, model, dataset, num_samples=3000, batch_size=5
|
|
|
labels_name = None
|
|
labels_name = None
|
|
|
if dataset is not None:
|
|
if dataset is not None:
|
|
|
labels_name = dataset.labels
|
|
labels_name = dataset.labels
|
|
|
- root_path = os.environ['HOME']
|
|
|
|
|
|
|
+ root_path = gen_user_home()
|
|
|
root_path = osp.join(root_path, '.paddlex')
|
|
root_path = osp.join(root_path, '.paddlex')
|
|
|
pre_models_path = osp.join(root_path, "pre_models")
|
|
pre_models_path = osp.join(root_path, "pre_models")
|
|
|
if not osp.exists(pre_models_path):
|
|
if not osp.exists(pre_models_path):
|