Exemple #1
0
    def setUpClass(cls) -> None:
        tests.execute_file(os.path.abspath(gen_c_optimize.__file__))

        cls.optimizer_file_name = "tiny_yolo_v2_yad2k_optimize.onnx"

        cls.module_file_dir = os.path.abspath(
            tiny_yolo_v2_yad2k_infer_c.__file__)

        cls.current_path = os.path.dirname(os.path.abspath(__file__))
        cls.onnx_file = os.path.join(cls.current_path, "onnx",
                                     cls.optimizer_file_name)
        cls.out_c_path = os.path.join(cls.current_path, "out_c_optimize")

        cls.optimizer_module_path = os.path.abspath(
            tiny_yolo_v2_yad2k_optimize_onnx.__file__)
        cls.optimizer_output_path = os.path.join(
            os.path.dirname(cls.optimizer_module_path), "onnx")
        cls.optimizer_output_file = os.path.join(cls.optimizer_output_path,
                                                 cls.optimizer_file_name)

        if not os.path.exists(os.path.join(cls.current_path, "onnx")):
            os.mkdir(os.path.join(cls.current_path, "onnx"))

        cls._generate_optimized_onnx()
        cls._generate_c()
Exemple #2
0
    def setUpClass(cls) -> None:
        cls.onnx_file_name = "tiny_yolo_v2_yad2k.onnx"
        cls.conv_onnx_path = os.path.abspath(
            tiny_yolo_v2_yad2k_conv_onnx.__file__)

        cls.current_path = os.path.dirname(os.path.abspath(__file__))
        cls.onnx_folder = os.path.join(cls.current_path, "onnx")
        cls.onnx_file = os.path.join(cls.onnx_folder, cls.onnx_file_name)
        cls.out_c_path = os.path.join(cls.current_path, "out_c")
        cls.c_path = os.path.join(cls.out_c_path, "qumico.c")

        tests.execute_file(cls.conv_onnx_path)
        cls._generate_c()
Exemple #3
0
    def test_gen_C(self):
        output = tests.read_from_output(lambda: tests.execute_file(self.gen_c_path))
        file_list = ["qumico.c", "qumico.so", "qumico.h", "qumico_type.h"]
        folder_list = [QUMICO_LIB, QUMICO_INCLUDE]

        self.assertTrue(tests.is_dir_contains(dirs=self.output_path, folder_list=folder_list, file_list=file_list))
        self.assertIn("Cソースを生成しました。出力先:", output)
Exemple #4
0
    def test_gen_c(self):
        res = tests.read_from_output(
            lambda: tests.execute_file(self.gen_c_path))

        file_list = ["numpy.c", "qumico.c", "qumico.so"]
        folder_list = ["include", "initializers", "lib"]

        self.assertIn("Cソースを生成しました。出力先:", res)
        self.assertTrue(
            tests.is_dir_contains(self.output_path,
                                  file_list=file_list,
                                  folder_list=folder_list))
Exemple #5
0
    def test_conv_onnx(self):
        output = tests.read_from_output(
            lambda: tests.execute_file(self.module_path))

        folder_list = ["model"]
        file_list = ["tiny_yolo_v2_yad2k.onnx"]

        self.assertTrue(
            tests.is_dir_contains(dirs=self.current_path,
                                  folder_list=folder_list))
        self.assertTrue(
            tests.is_dir_contains(dirs=self.output_path, file_list=file_list))
        self.assertIn("tiny_yolo_v2_yad2k.onnxを作成しました。", output)
Exemple #6
0
 def test_optimize_onnx(self):
     tests.execute_file(self.module_path)
     file_list = ["tiny_yolo_v2_yad2k_optimize.onnx"]
     self.assertTrue(tests.is_dir_contains(dirs=self.output_path, file_list=file_list))
Exemple #7
0
 def test_infer_c(self):
     output = tests.read_from_output(
         lambda: tests.execute_file(self.module_file_dir))
     self.assertIn("sheep", output)
     self.assertIn("person", output)
     self.assertIn("cow", output)
Exemple #8
0
 def _generate_optimized_onnx(cls):
     tests.execute_file(cls.optimizer_module_path)
     shutil.copyfile(
         cls.optimizer_output_file,
         os.path.join(cls.current_path, "onnx", cls.optimizer_file_name))
Exemple #9
0
    def test_vgg16_to_onnx(self):
        output = tests.read_from_output(lambda: tests.execute_file(self.vgg16_to_onnx_path))

        self.assertTrue(tests.is_dir_contains(dirs=self.output_path, file_list=["vgg16.onnx"]))
        self.assertIn("onnx/vgg16.onnxを作成しました。", output)
Exemple #10
0
 def test_vgg16_optimize_onnx(self):
     try:
         tests.execute_file(self.vgg16_optimize_onnx_path)
     except Exception:
         self.fail("The was an Exception when executing " +
                   vgg16_optimize_onnx.__name__)