From 87a1222ce5eccd8ca3dc2f93c9b60192b03d7a9d Mon Sep 17 00:00:00 2001 From: sunyanfang01 Date: Tue, 19 May 2020 21:35:58 +0800 Subject: [PATCH] fix the vis.py --- paddlex/interpret/visualize.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paddlex/interpret/visualize.py b/paddlex/interpret/visualize.py index f33904b..eaf0a78 100644 --- a/paddlex/interpret/visualize.py +++ b/paddlex/interpret/visualize.py @@ -23,6 +23,13 @@ from .core.interpretation import Interpretation 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, model, dataset=None, @@ -109,7 +116,7 @@ def get_normlime_interpreter(img, model, dataset, num_samples=3000, batch_size=5 labels_name = None if dataset is not None: labels_name = dataset.labels - root_path = os.environ['HOME'] + root_path = gen_user_home() root_path = osp.join(root_path, '.paddlex') pre_models_path = osp.join(root_path, "pre_models") if not osp.exists(pre_models_path): -- GitLab