diff --git a/demo/prune/train.py b/demo/prune/train.py index 2fd535399a7163dcc29661ce4c4f8abfdd35bbca..ba5e3486ee5cbe530f7d0c3b97b737fdfd030334 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 7cb088b440f4037203c837830b1b853ad99ab100..996b040539c624bbe33295a1e62fd685f0a2c0f0 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 8d5cfa003d8b7077224ae2f54194069aadc3dc90..d7414b0973226425e9627137c185a39f26603fb9 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 dbfeb2b042139ec85b390ccd6f242c0aa93e8835..be3751bc55a512fc51d6d3f10334d61c112042e3 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 5691402122540f4426e1e1e63f6642cd10cfcb4c..96f8dca60e928056aa6761501d9355b569161e53 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)