From cd11800075496a4db62c83f2848971c8c803341b Mon Sep 17 00:00:00 2001 From: whs Date: Wed, 25 Mar 2020 11:34:48 +0800 Subject: [PATCH] Fix import in windows. (#153) --- demo/prune/train.py | 2 +- demo/quant/quant_aware/train.py | 4 ++-- demo/quant/quant_post/eval.py | 3 ++- demo/quant/quant_post/export_model.py | 4 ++-- demo/quant/quant_post/quant_post.py | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/demo/prune/train.py b/demo/prune/train.py index 2fd53539..ba5e3486 100644 --- a/demo/prune/train.py +++ b/demo/prune/train.py @@ -8,10 +8,10 @@ import math import time import numpy as np import paddle.fluid as fluid +sys.path[0] = os.path.join(os.path.dirname("__file__"), os.path.pardir) from paddleslim.prune import Pruner, save_model from paddleslim.common import get_logger from paddleslim.analysis import flops -sys.path.append(sys.path[0] + "/../") import models from utility import add_arguments, print_arguments diff --git a/demo/quant/quant_aware/train.py b/demo/quant/quant_aware/train.py index 7cb088b4..996b0405 100644 --- a/demo/quant/quant_aware/train.py +++ b/demo/quant/quant_aware/train.py @@ -8,8 +8,8 @@ import math import time import numpy as np import paddle.fluid as fluid -sys.path.append(sys.path[0] + "/../../../") -sys.path.append(sys.path[0] + "/../../") +sys.path[0] = os.path.join( + os.path.dirname("__file__"), os.path.pardir, os.path.pardir) from paddleslim.common import get_logger from paddleslim.analysis import flops from paddleslim.quant import quant_aware, quant_post, convert diff --git a/demo/quant/quant_post/eval.py b/demo/quant/quant_post/eval.py index 8d5cfa00..d7414b09 100755 --- a/demo/quant/quant_post/eval.py +++ b/demo/quant/quant_post/eval.py @@ -20,7 +20,8 @@ import functools import paddle import paddle.fluid as fluid -sys.path.append('../../') +sys.path[0] = os.path.join( + os.path.dirname("__file__"), os.path.pardir, os.path.pardir) import imagenet_reader as reader from utility import add_arguments, print_arguments diff --git a/demo/quant/quant_post/export_model.py b/demo/quant/quant_post/export_model.py index dbfeb2b0..be3751bc 100755 --- a/demo/quant/quant_post/export_model.py +++ b/demo/quant/quant_post/export_model.py @@ -8,9 +8,9 @@ import math import time import numpy as np import paddle.fluid as fluid -sys.path.append(sys.path[0] + "/../../../") +sys.path[0] = os.path.join( + os.path.dirname("__file__"), os.path.pardir, os.path.pardir) from paddleslim.common import get_logger -sys.path.append(sys.path[0] + "/../../") import models from utility import add_arguments, print_arguments diff --git a/demo/quant/quant_post/quant_post.py b/demo/quant/quant_post/quant_post.py index 56914021..96f8dca6 100755 --- a/demo/quant/quant_post/quant_post.py +++ b/demo/quant/quant_post/quant_post.py @@ -9,10 +9,10 @@ import time import numpy as np import paddle.fluid as fluid -sys.path.append(sys.path[0] + "/../../../") +sys.path[0] = os.path.join( + os.path.dirname("__file__"), os.path.pardir, os.path.pardir) from paddleslim.common import get_logger from paddleslim.quant import quant_post -sys.path.append(sys.path[0] + "/../../") from utility import add_arguments, print_arguments import imagenet_reader as reader _logger = get_logger(__name__, level=logging.INFO) -- GitLab