未验证 提交 a30b8c3f 编写于 作者: L Leo Chen 提交者: GitHub

Add enable_static() for model with static graph (#1498)

* add enable_static()

* follow comments

* remove blank line
上级 7fd1f891
......@@ -22,6 +22,7 @@ from functools import reduce
from PIL import Image
import cv2
import numpy as np
import paddle
import paddle.fluid as fluid
from preprocess import preprocess, Resize, Normalize, Permute, PadStride
from visualize import visualize_box_mask
......@@ -509,6 +510,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--model_dir",
......
......@@ -146,5 +146,7 @@ class TestDataset(unittest.TestCase):
if __name__ == '__main__':
import paddle
paddle.enable_static()
logging.basicConfig()
unittest.main()
......@@ -168,4 +168,6 @@ class TestReader(unittest.TestCase):
if __name__ == '__main__':
import paddle
paddle.enable_static()
unittest.main()
......@@ -112,4 +112,6 @@ class TestReaderYAML(unittest.TestCase):
if __name__ == '__main__':
import paddle
paddle.enable_static()
unittest.main()
......@@ -120,4 +120,6 @@ class TestLeftPoolOp(TestRightPoolOp):
if __name__ == "__main__":
import paddle
paddle.enable_static()
unittest.main()
......@@ -91,4 +91,5 @@ class TestSSD(TestFasterRCNN):
if __name__ == '__main__':
paddle.enable_static()
unittest.main()
......@@ -26,6 +26,7 @@ import numpy as np
from collections import OrderedDict
from paddleslim.dist.single_distiller import merge, l2_loss
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
from ppdet.data.reader import create_reader
......@@ -371,6 +372,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-r",
......
......@@ -29,6 +29,7 @@ from paddleslim.dist.single_distiller import merge, l2_loss
from paddleslim.prune import Pruner
from paddleslim.analysis import flops
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
from ppdet.data.reader import create_reader
......@@ -359,6 +360,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-t",
......
......@@ -27,6 +27,7 @@ import numpy as np
import datetime
from collections import deque
import paddle
from paddle import fluid
from ppdet.experimental import mixed_precision_context
......@@ -378,6 +379,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-r",
......
......@@ -23,6 +23,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
import paddle.fluid as fluid
from paddleslim.prune import Pruner
from paddleslim.analysis import flops
......@@ -199,6 +200,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--json_eval",
......
......@@ -22,6 +22,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -97,6 +98,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--output_dir",
......
......@@ -26,6 +26,7 @@ import glob
import numpy as np
from PIL import Image
import paddle
from paddle import fluid
from paddleslim.prune import Pruner
from paddleslim.analysis import flops
......@@ -223,6 +224,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--infer_dir",
......
......@@ -29,6 +29,7 @@ import datetime
from collections import deque
from paddleslim.prune import Pruner
from paddleslim.analysis import flops
import paddle
from paddle import fluid
from ppdet.experimental import mixed_precision_context
......@@ -347,6 +348,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-r",
......
......@@ -23,6 +23,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
import paddle.fluid as fluid
from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results, json_eval_results
......@@ -156,6 +157,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--json_eval",
......
......@@ -22,6 +22,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 3)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -90,6 +91,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--output_dir",
......
......@@ -26,6 +26,7 @@ import glob
import numpy as np
from PIL import Image
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -168,6 +169,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--infer_dir",
......
......@@ -28,6 +28,7 @@ import datetime
from collections import deque
import shutil
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -296,6 +297,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--loss_scale",
......
......@@ -27,6 +27,7 @@ import numpy as np
import datetime
from collections import deque
import paddle
from paddle import fluid
from ppdet.experimental import mixed_precision_context
from ppdet.core.workspace import load_config, merge_config, create
......@@ -167,6 +168,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--output_eval",
......
......@@ -22,6 +22,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
import paddle.fluid as fluid
from ppdet.utils.eval_utils import parse_fetches, eval_run, eval_results, json_eval_results
......@@ -161,6 +162,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--json_eval",
......
......@@ -23,6 +23,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -71,6 +72,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--output_dir",
......
......@@ -22,6 +22,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -94,6 +95,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--output_dir",
......
......@@ -23,6 +23,7 @@ parent_path = os.path.abspath(os.path.join(__file__, *(['..'] * 2)))
if parent_path not in sys.path:
sys.path.append(parent_path)
import paddle
import paddle.fluid as fluid
import numpy as np
import cv2
......@@ -270,6 +271,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-f",
......
......@@ -27,6 +27,7 @@ import numpy as np
import six
from PIL import Image
import paddle
from paddle import fluid
from ppdet.core.workspace import load_config, merge_config, create
......@@ -233,6 +234,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"--infer_dir",
......
......@@ -30,6 +30,7 @@ import six
from collections import deque
from paddle.fluid import profiler
import paddle
from paddle import fluid
from paddle.fluid.layers.learning_rate_scheduler import _decay_step_counter
from paddle.fluid.optimizer import ExponentialMovingAverage
......@@ -316,6 +317,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-r",
......
......@@ -28,6 +28,7 @@ import random
import datetime
import six
from collections import deque
import paddle
from paddle.fluid import profiler
from paddle import fluid
......@@ -309,6 +310,7 @@ def main():
if __name__ == '__main__':
paddle.enable_static()
parser = ArgsParser()
parser.add_argument(
"-r",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册