1# Copyright 2020 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15"""maskrcnn testing script.""" 16 17import os 18import pytest 19from tests.st.model_zoo_tests import utils 20 21 22@pytest.mark.level1 23@pytest.mark.platform_arm_ascend_training 24@pytest.mark.platform_x86_ascend_training 25@pytest.mark.env_onecard 26def test_maskrcnn_export(): 27 """ 28 export maskrcnn air. 29 """ 30 old_list = ["(config=config)", "(net, param_dict_new)"] 31 new_list = ["(config=config)\\n '''", "(net, param_dict_new)\\n '''"] 32 33 cur_path = os.getcwd() 34 model_path = "{}/../../../../tests/models/official/cv".format(cur_path) 35 model_name = "maskrcnn" 36 utils.copy_files(model_path, cur_path, model_name) 37 cur_model_path = os.path.join(cur_path, model_name) 38 39 utils.exec_sed_command(old_list, new_list, os.path.join(cur_model_path, "export.py")) 40 # ckpt_path = os.path.join(utils.ckpt_root, "bgcf/bgcf_trained.ckpt") 41 exec_export_shell = "cd {}; python export.py --config_path default_config.yaml".format(model_name) 42 os.system(exec_export_shell) 43 assert os.path.exists(os.path.join(cur_model_path, "{}.air".format(model_name))) 44 45if __name__ == '__main__': 46 test_maskrcnn_export() 47