Example #1
0
    def test_main_process(self):
        """ Main process of unit test. """

        # initialization
        comp = ResizeImageProcessor(
            dyda_config_path=dyda_config_ResizeImageProcessor)

        # run component
        comp.reset()
        comp.input_data = [input_data]
        comp.run()

        # compare output_data with reference
        ref_data = output_ResizeImageProcessor
        tar_data = comp.output_data[0]
        img_diff = lab_tools.img_comparator(tar_data, ref_data)
        self.assertEqual(img_diff, 0.0)

        # compare results with reference
        ref_data = results_ResizeImageProcessor
        tar_data = comp.results[0]
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #2
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads"
                      "/b6fec0ae2bc4c0913e3e765c2a87b135/"
                      "dyda.config.inceptionv3_unittest")
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)

        img_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "4fa6b8a454f9b4041bdde316bac85a27/IMAG1450.jpg")
        ref_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "1ca61414f75fa6b93e09944a3bf1b66b/"
                   "ref_json.json.inceptionv3_unittest")
        img = lab_tools.pull_img_from_gitlab(img_url)
        ref_data = lab_tools.pull_json_from_gitlab(ref_url)

        classifier = ClassifierInceptionv3(dyda_config_path=dyda_config)
        classifier.input_data = [img]
        classifier.run()

        tar_data = classifier.results[0]
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):

        # pull test data from gitlab
        config_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '8710dfd057501758190778cb056e4449/dyda.config'
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            'a9324bdf32ed5a1e237be94fbc74c5d5/input.json'
        input_data = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '0f801ae6692bcc168ba1c5045b806c78/res.json'
        output_data = lab_tools.pull_json_from_gitlab(output_url)

        # initialization
        determinator_ = DeterminatorByRoi(dyda_config_path=dyda_config)

        # run determinator
        determinator_.reset()
        determinator_.input_data.append(input_data)
        determinator_.run()

        # compare results with reference
        ref_data = output_data
        tar_data = determinator_.results
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):

        # pull test data from gitlab
        config_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '2b588582c1ad5b901f6b4cc1c8f81e15/dyda.config'
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)

        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '41ed033f30b132a0a48d7ba214f75c41/00000015.json'
        input_data = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '73b6ab545229971f1149ade93dc1ca8f/00000015.json'
        output_data = lab_tools.pull_json_from_gitlab(output_url)

        # initialization
        determinator_ = DeterminatorConfidenceThreshold(dyda_config)

        # run determinator
        determinator_.reset()
        determinator_.metadata[0] = tools.remove_extension(
            input_data["filename"], 'base-only')
        determinator_.input_data.append(input_data)
        determinator_.run()

        # compare results with reference
        ref_path = output_data
        tar_path = determinator_.results
        report = dict_comparator.get_diff(ref_path, tar_path)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #5
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                      "dbd906035055b99da05308aa927b9f4a/DetectorYOLO.config")
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)

        ref_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "6ce02b726d96edaf4cb4e4108fb9ba9f/DetectorYOLO_output.json")
        ref_data = lab_tools.pull_json_from_gitlab(ref_url)

        detector_yolo = DetectorYOLO(dyda_config_path=dyda_config)

        input_path = '/home/shared/DT42/test_data/test_detector/dog.jpg'
        detector_yolo.input_data = [image.read_img(input_path)]
        detector_yolo.run()

        tar_data = detector_yolo.results[0]
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])

        # Since the filename depending on time stamp, it wont match anyway
        for mis_match in report['mismatch_val']:
            for tar_key in mis_match['tar_key']:
                if tar_key == 'filename':
                    continue
                else:
                    self.assertEqual(report['mismatch_val'], [])
Example #6
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                      "abf5cf6f40a4b31216b0dabbe81a6863/"
                      "dyda.config.mobilenet_unittest")
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)

        img_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "4fa6b8a454f9b4041bdde316bac85a27/IMAG1450.jpg")
        ref_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "8ea9ac61e3403981eca23c658b2cdac7/"
                   "ref_results.json.mobilenet")
        img = lab_tools.pull_img_from_gitlab(img_url)
        ref_data = lab_tools.pull_json_from_gitlab(ref_url)

        classifier = ClassifierMobileNet(dyda_config_path=dyda_config)
        classifier.input_data = [img]
        classifier.run()

        tar_data = classifier.results[0]
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #7
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/"
                      "uploads/6bd42ac664cecf4fdc29a4ed894874d2/"
                      "dyda.config.ClassifierAoiCornerAvg")
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)

        img_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "697de0fe3c7d5a530674ddd996a0129a/NG_TYPE2_0063.png")
        ref_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "1cd293379a63b3a843bfe47e754e495f/"
                   "test_ClassifierAoiCornerAvg.json")
        img = lab_tools.pull_img_from_gitlab(img_url)
        ref_data = lab_tools.pull_json_from_gitlab(ref_url)[2]["results"][0]

        classifier = ClassifierAoiCornerAvg(dyda_config_path=dyda_config)
        classifier.input_data = [img]
        classifier.run()

        tar_data = classifier.results[0]
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):

        config_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '2f4b1e105fad5d935e83fa8e608c395e/'\
            'dyda.config.TimeScaleShiftConverter'
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            'a25e50ea3b063d3e57aed402de9d0d25/input_list.json'
        input_list = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '4e8e4849534e68152507bdf3640d5bd1/output.json'
        output_list = lab_tools.pull_json_from_gitlab(output_url)

        # initialization
        converter_ = TimeScaleShiftConverter(dyda_config)

        for i in range(len(input_list)):

            # run converter
            converter_.reset()
            converter_.input_data.append(
                tools.parse_json(input_list[i]))
            converter_.run()

            # compare results with reference
            ref_data = output_list[i]
            tar_data = converter_.results
            if not ref_data == [] and not tar_data == []:
                report = dict_comparator.get_diff(ref_data, tar_data)
                self.assertEqual(report['extra_field'], [])
                self.assertEqual(report['missing_field'], [])
                self.assertEqual(report['mismatch_val'], [])
Example #9
0
    def test_main_process(self):
        # pull test data from gitlab
        img_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
                  'd2ebc6170f05578273b934cfb6ed7344/pict000301.jpg'

        json_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
                   'c8457db3f0d2b1ddb1fd7f6730168b9c/metadata_pic301.json'

        result_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
                     '952964ae5dbdb06eec74d716d7636576/pict000301_result.json'

        img = lab_tools.pull_img_from_gitlab(img_url)
        meta_data = lab_tools.pull_json_from_gitlab(json_url)
        ref_data = lab_tools.pull_json_from_gitlab(result_url)

        # initialization
        data = [img, meta_data]
        data_preprocessor_ = preprocessor.LabelMeDataPreProcessor()
        data_preprocessor_.meta_data = meta_data

        data_preprocessor_.input_data = data
        data_preprocessor_.run()

        tar_data = data_preprocessor_.results
        ref_data['data_path'] = []
        report = dict_comparator.get_diff(ref_data, tar_data)

        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):

        config_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      'bb1bfe0785760aa7308f139a16bc4e76/'
                      'path_label_converter_dyda.config')
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        input_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                     '7ad69fd8e0674843c74382f4d2ef6a16/'
                     'path_label_converter_input.json')
        input_list = lab_tools.pull_json_from_gitlab(input_url)
        output_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      'c2317edcab9d460e193827f1eb213568/'
                      'path_label_converter_results.json')

        # initialization
        converter_ = PathLabelConverter(dyda_config)
        converter_.reset()
        converter_.input_data = {'data_path': input_list}
        converter_.run()

        ref_data = lab_tools.pull_json_from_gitlab(output_url)
        tar_data = converter_.results
        if not ref_data == [] and not tar_data == []:
            report = dict_comparator.get_diff(ref_data, tar_data)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
Example #11
0
    def test_main_process(self):

        config_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      '99e8dae78033b647562b72835aa84f5e/'
                      'dyda.config.validator')
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        output_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      'e9d7eea7eff43a67ac4c8f9bae3ec3ee/'
                      'ref_results_validator.json')
        label_txt_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/'
                         'uploads/f1cf0a5cacb0e6dca35f0b400f9ce9e6/labels.txt')
        labels = lab_tools.pull_json_from_gitlab(label_txt_url)

        results_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/'
                       'uploads/6350c824e163ead49f4849145a3d116d/'
                       'classification.txt')
        classification_results = lab_tools.pull_json_from_gitlab(results_url)

        # initialization
        validator = ClassificationValidator(dyda_config)
        validator.reset()
        validator.input_data = [classification_results, labels]
        validator.run()

        ref_data = lab_tools.pull_json_from_gitlab(output_url)
        tar_data = validator.results
        if not ref_data == [] and not tar_data == []:
            report = dict_comparator.get_diff(ref_data, tar_data)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
Example #12
0
    def test_main_process(self):

        config_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      'a38ca41418635e32dcbc82a46a25937f/'
                      'DetectionValidator.config')
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        ref_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                   'b5b1692ae296653840758710304fb17f/ref_data.json')
        ref_data = lab_tools.pull_json_from_gitlab(ref_url)
        gt_url = (
            'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
            '66fbbb03bdc4be60e78a3385a457dfc5/ground_truth_data_all.json')
        gt = lab_tools.pull_json_from_gitlab(gt_url)
        det_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                   'bd96dfe182f45acc7c1034d1fdc11c9c/prediction_data_all.json')
        det = lab_tools.pull_json_from_gitlab(det_url)

        # initialization
        validator = DetectionValidator(dyda_config)
        validator.reset()
        validator.input_data = [det, gt]
        validator.run()

        tar_data = validator.results
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):

        # pull test data from gitlab
        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '06e852b64cd24cdb017a56c540e195db/FrameSelectorDownsampleFirst_input_list.json'
        input_list = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '6ce81dd346759aef1d8f4cc81675662e/FrameSelectorDownsampleFirst_output_list.json'
        output_list = lab_tools.pull_json_from_gitlab(output_url)

        # initialization
        frame_selector_ = FrameSelectorDownsampleFirst()

        for i in range(len(input_list)):

            # run frame_selector
            frame_selector_.reset()
            frame_selector_.metadata[0] = tools.remove_extension(
                input_list[i]['filename'], 'base-only')
            frame_selector_.run()

            # compare results with reference
            ref_data = output_list[i]
            tar_data = frame_selector_.results
            report = dict_comparator.get_diff(ref_data, tar_data)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
Example #14
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '79187835280b7adc8149e5e9a8e6ec9c/DeterminatorTargetLabel.config'
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '4cdb639a0f0862f504e3223713da1c49/'\
            'DeterminatorTargetLabel_input.json'
        input_data = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            'fd45424cee6c68c7de28fc16f6af734d/'\
            'DeterminatorTargetLabel_output.json'
        output_data = lab_tools.pull_json_from_gitlab(output_url)

        # initialization
        determinator_ = DeterminatorTargetLabel(dyda_config_path=dyda_config)

        # run determinator
        determinator_.reset()
        determinator_.metadata[0] = tools.remove_extension(
            input_data["filename"], 'base-only')
        determinator_.input_data.append(input_data)
        determinator_.run()

        # compare results with reference
        ref_path = output_data
        tar_path = determinator_.results[0]
        report = dict_comparator.get_diff(ref_path, tar_path)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #15
0
def check_result(tar, ref, input_filename, all_pass, ignore_keys=[]):
    if tar == [] and ref == []:
        pass
    else:
        report = dict_comparator.get_diff(ref, tar, ignore_keys=ignore_keys)
        if report['extra_field'] == [] and \
                report['missing_field'] == []and \
                report['mismatch_val'] == []:
            pass
        else:
            print('[Launcher] Output is different with reference: %s' %
                  input_filename)
            all_pass = False
    return all_pass
    def test_main_process(self):
        """ Main process of unit test. """

        # initialization
        comp = ResizeBoxProcessor()

        # run component
        comp.reset()
        comp.input_data = [resize_info, input_data]
        comp.run()

        ## compare output_data with reference
        tar_data = comp.results
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):
        """ Main process of unit test. """

        # initialization
        comp = DeterminatorSizeThreshold(dyda_config_path=dyda_config_pixel)

        # run component
        comp.reset()
        comp.input_data = input_data
        comp.run()

        # compare output_data with reference
        ref_data = output_data
        tar_data = comp.results
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):
        # pull test data from gitlab
        tar_url = "https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"\
                  "3111a2fd3690b775e7e088aa97d26330/labelme_example.tar.gz"

        golden1_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
                      '572998d818f6bceb5bf89346427243b7/golden_pic303.json'

        golden2_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
                      '64d34d53518c44a68b7904ed4c1b8265/golden_pic301.json'

        output_list = list()
        output_list.append(lab_tools.pull_json_from_gitlab(golden1_url))
        output_list.append(lab_tools.pull_json_from_gitlab(golden2_url))

        # download tar.gz file
        self.pull_gz_from_gitlab(tar_url)

        # unzip the tar.gz file
        targz_path = os.path.basename(tar_url)
        tar = tarfile.open(targz_path, "r")
        tar.extractall()

        # get the all the image path in the folder
        unzip_folder = os.path.basename(tar_url)[:-7]
        img_paths = image.find_images(unzip_folder)

        # initialization
        data_reader_ = reader.LabelMeDataReader()

        for idx, img_path in enumerate(img_paths):
            data_reader_.reset_results()
            data_reader_.img_path = img_path
            data_reader_.run()

            # compare results with reference
            ref_data = output_list[idx]
            tar_data = data_reader_.results
            ref_data['folder'] = ref_data['folder'].replace('/home/hki541/dt42-dyda/tests', os.getcwd())
            report = dict_comparator.get_diff(ref_data, tar_data)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
Example #19
0
    def test_main_process(self):
        """ Main process of unit test. """

        # initialization
        comp = AccumulatorObjectNumber(
            dyda_config_path=dyda_config_AccumulatorObjectNumber_default)

        # run component

        comp.reset()
        comp.input_data = input_data
        comp.run()
        # compare output_data with reference
        ref_data = output_AccumulatorObjectNumber_dict_list
        tar_data = comp.results
        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):
        """ Main process of unit test. """

        # initialization
        comp = DeterminatorMotion()

        # run component
        for i in range(len(input_data)):
            comp.reset()
            comp.input_data = input_data[i]
            comp.run()

            # compare output_data with reference
            ref_data = output_DeterminatorMotion[i]
            tar_data = comp.results
            report = dict_comparator.get_diff(ref_data, tar_data)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
Example #21
0
    def test_main_process(self):

        config_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      '07478873045e3731eb2336445f87e080/dyda.config')
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        output_url = ('https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'
                      'a9fb65dbb1684979b5b3f6f8bce1784b/'
                      'uncertainty_unit_test_results.json')

        # initialization
        analyzer_ = UncertaintyAnalyzerSimple(dyda_config)
        analyzer_.reset()
        analyzer_.run()

        ref_data = lab_tools.pull_json_from_gitlab(output_url)[0]
        tar_data = analyzer_.results[0]
        if not ref_data == [] and not tar_data == []:
            report = dict_comparator.get_diff(ref_data, tar_data)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
Example #22
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            'abc67841cfb173c22cc13087fdd4d7b2/dyda.config'
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '83db1facaef1bc83efc2b9ed25256ad1/park_input_list.json'
        input_list = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '775252d8456257f3364f788556bb553c/park_output_list.json'
        output_list = lab_tools.pull_json_from_gitlab(output_url)
        frame_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            'aa4675a8057f3ae79bf5c0153cdfc69e/'\
            'DeterminatorParkingLotStatus_frame_list.json'
        frame_list = lab_tools.pull_json_from_gitlab(frame_url)

        # initialization
        determinator_ = DeterminatorParkingLotStatus(
            dyda_config_path=dyda_config)

        # run determinator
        for i in range(len(output_list)):

            # run determinator
            determinator_.reset()
            determinator_.input_data.append([image.read_img(frame_list[i])])
            determinator_.input_data.append(input_list[i][0])
            determinator_.input_data.append(input_list[i][1])
            determinator_.input_data.append(input_list[i][2])
            determinator_.run()

            # compare results with reference
            if not determinator_.results == []:
                ref_data = output_list[i][0]
                tar_data = determinator_.results[0]
                report = dict_comparator.get_diff(ref_data, tar_data)
                self.assertEqual(report['extra_field'], [])
                self.assertEqual(report['missing_field'], [])
                self.assertEqual(report['mismatch_val'], [])
Example #23
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads"
                      "/418f17cdcdb4c9ee7555ef467e042a8c/dyda.config")
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)

        cwd = os.getcwd()
        filename = ".testing_img.jpg"
        local_path = os.path.join(cwd, filename)

        img_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "4fa6b8a454f9b4041bdde316bac85a27/IMAG1450.jpg")
        img = lab_tools.pull_img_from_gitlab(img_url, save_to=local_path)

        ref_url = ("https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/"
                   "4d57dd72be420cda1acea39f7665d76c/"
                   "ref_data.json.framereader_unittest")
        ref_data = lab_tools.pull_json_from_gitlab(ref_url)

        reader = FrameReader(dyda_config_path=dyda_config)
        reader.input_data = [local_path]
        reader.run()

        tar_data = reader.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])

        # Since the filepath depending on cwd, the folder wont match anyway
        for mis_match in report['mismatch_val']:
            for tar_key in mis_match['tar_key']:
                if isinstance(tar_key, list) and tar_key[0] == 'data_path':
                    _tar_val = os.path.basename(mis_match['tar_val'])
                    _ref_val = os.path.basename(mis_match['ref_val'])
                    self.assertEqual(_tar_val, _ref_val)
                else:
                    self.assertEqual(report['mismatch_val'], [])
        os.remove(local_path)
 def test_main_process(self):
     ref_data = [['others', '1.00'], ['others', '1.00'], ['others', '0.90'],
                 ['person', '0.90'], ['others', '0.83'], ['others', '0.80']]
     r1 = lab_tools.output_pred_classification("", 1.0, "others")
     r2 = lab_tools.output_pred_classification("", 0.9, "person")
     r3 = lab_tools.output_pred_classification("", 0.8, "others")
     r4 = lab_tools.output_pred_classification("", 0.7, "others")
     r5 = lab_tools.output_pred_classification("", 0.2, "person")
     r6 = lab_tools.output_pred_classification("", 0.9, "others")
     results = []
     d = DeterminatorByAggregatedDataSingle()
     for r in [r1, r2, r3, r4, r5, r6]:
         d.input_data = r
         d.run()
         results.append([
             d.results["annotations"][0]["label"],
             "%0.2f" % d.results["annotations"][0]["confidence"]
         ])
     report = dict_comparator.get_diff(ref_data, results)
     self.assertEqual(report['extra_field'], [])
     self.assertEqual(report['missing_field'], [])
     self.assertEqual(report['mismatch_val'], [])
Example #25
0
    def test_main_process(self):
        """ Main process of unit test. """

        # initialization
        comp = ExtractNonBlackImageProcessor()

        # run component
        comp.reset()
        comp.input_data = input_data
        comp.run()

        # compare output_data with reference
        tar_data = comp.output_data
        img_diff = lab_tools.img_comparator(tar_data, ref_output)
        self.assertEqual(img_diff, 0.0)

        # compare results with reference
        tar_data = comp.results
        report = dict_comparator.get_diff(ref_results, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #26
0
    def test_main_process(self):

        # pull test data from gitlab
        config_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '36356e92cad4a608d4c84bba769c0d53/'\
            'dyda.config.DeterminatorCharacter'
        dyda_config = lab_tools.pull_json_from_gitlab(config_url)
        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '521feb8def6e63d6e187622b171b7233/input_list.json'
        input_list = lab_tools.pull_json_from_gitlab(input_url)
        output_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
            '9f25865b93a133bdec459ace16de8ccd/output_list.json'
        output_list = lab_tools.pull_json_from_gitlab(output_url)

        # initialization
        determinator_ = DeterminatorCharacter(dyda_config_path=dyda_config)
        # run determinator
        for i in range(len(input_list)):

            # run determinator
            determinator_.reset()
            determinator_.input_data.append(image.read_img(input_list[i]))
            determinator_.input_data.append(
                tools.parse_json(tools.replace_extension(
                    input_list[i], 'json')))
            determinator_.run()

            # compare results with reference
            if not determinator_.results == []:
                ref_data = output_list[i]
                tar_data = determinator_.results
                for j in range(len(ref_data)):
                    for k in range(len(ref_data[j])):
                        report = dict_comparator.get_diff(
                            ref_data[j][k], tar_data[j][k])
                        self.assertEqual(report['extra_field'], [])
                        self.assertEqual(report['missing_field'], [])
                        self.assertEqual(report['mismatch_val'], [])
    def test_main_process(self):
        """ Test simple case. """

        dyda_config = {"OutputGeneratorCombineDetCla": {}}
        # initialization
        comp = OutputGeneratorCombineDetCla(dyda_config_path=dyda_config)
        # run component
        comp.reset()
        comp.input_data = combinedetcla_input
        comp.run()

        # compare results with reference
        ref_data = {
            'size': {
                'height': 480,
                'width': 640
            },
            'folder':
            '',
            'filename':
            '',
            'annotations': [{
                'type': 'classification',
                'bottom': 350,
                'top': 82,
                'left': 319,
                'right': 587,
                'labinfo': {},
                'label': 'George',
                'confidence': -1,
                'id': 0
            }]
        }
        tar_data = comp.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
        """ Test append case. """
        dyda_config_append = {
            "OutputGeneratorCombineDetCla": {
                "behavior": "append",
                "cla_key_name": {
                    "label": "person"
                }
            }
        }
        # initialization
        comp = OutputGeneratorCombineDetCla(
            dyda_config_path=dyda_config_append)
        # run component
        comp.reset()
        comp.input_data = combinedetcla_input
        comp.run()

        # compare results with reference
        ref_data = {
            'size': {
                'height': 480,
                'width': 640
            },
            'folder':
            '',
            'filename':
            '',
            'annotations': [{
                'type': 'detection',
                'person': 'George',
                'top': 82,
                'right': 587,
                'labinfo': {},
                'label': 'face',
                'cla_labinfo': {},
                'cla_type': 'classification',
                'bottom': 350,
                'left': 319,
                'confidence': -1.0,
                'id': 0,
                'cla_confidence': -1
            }]
        }
        tar_data = comp.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #28
0
    def test_main_process(self):

        # test the case with using HOG
        dyda_config = {"FaceDetector": {"model": "hog"}}

        ref_data = {'filename': '', 'size': {'width': 960, 'height': 544},
                    'annotations': [{'left': 414, 'right': 637, 'top': 192,
                                     'labinfo': {}, 'bottom': 415,
                                     'type': 'detection', 'id': 0,
                                     'label': 'face', 'confidence': -1.0}],
                    'folder': ''}

        face_detector = FaceDetector(dyda_config_path=dyda_config)

        input_url = 'https://gitlab.com/DT42/galaxy42/dt42-dyda/uploads/'\
                    'a73f92e9b271420d48f70481f56944c4/2019-03-15-111527.jpg'

        input_data = lab_tools.pull_img_from_gitlab(input_url)
        face_detector.input_data = input_data.copy()
        face_detector.run()

        tar_data = face_detector.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])

        # Since the filename depending on time stamp, it wont match anyway
        for mis_match in report['mismatch_val']:
            for tar_key in mis_match['tar_key']:
                if tar_key == 'filename':
                    continue
                else:
                    self.assertEqual(report['mismatch_val'], [])

        # test the case with list input
        dyda_config = {"FaceDetector": {"model": "hog"}}

        face_detector = FaceDetector(dyda_config_path=dyda_config)

        input_data = lab_tools.pull_img_from_gitlab(input_url)
        face_detector.input_data = [input_data.copy()]
        face_detector.run()

        tar_data = face_detector.results

        report = dict_comparator.get_diff([ref_data], tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])

        # Since the filename depending on time stamp, it wont match anyway
        for mis_match in report['mismatch_val']:
            for tar_key in mis_match['tar_key']:
                if tar_key == 'filename':
                    continue
                else:
                    self.assertEqual(report['mismatch_val'], [])

        # test the case with using CNN
        dyda_config = {"FaceDetector": {"model": "cnn"}}

        ref_data = {'annotations': [{'top': 200, 'confidence': -1.0,
                                     'labinfo': {}, 'type': 'detection',
                                     'right': 627, 'bottom': 404,
                                     'label': 'face', 'left': 424, 'id': 0}],
                    'filename': '', 'folder': '',
                    'size': {'width': 960, 'height': 544}}

        face_detector = FaceDetector(dyda_config_path=dyda_config)

        face_detector.input_data = input_data.copy()
        face_detector.run()

        tar_data = face_detector.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])

        # Since the filename depending on time stamp, it wont match anyway
        for mis_match in report['mismatch_val']:
            for tar_key in mis_match['tar_key']:
                if tar_key == 'filename':
                    continue
                else:
                    self.assertEqual(report['mismatch_val'], [])

        # test the case with specify upsample_times
        dyda_config = {"FaceDetector": {"model": "cnn",
                                           "upsample_times": 3}}

        ref_data = {'folder': '', 'filename': '',
                    'annotations': [{'right': 613, 'top': 165, 'left': 394,
                                     'label': 'face', 'bottom': 384,
                                     'id': 0, 'confidence': -1.0,
                                     'labinfo': {}, 'type': 'detection'}],
                    'size': {'width': 960, 'height': 544}}

        face_detector = FaceDetector(dyda_config_path=dyda_config)

        face_detector.input_data = input_data.copy()
        face_detector.run()
        tar_data = face_detector.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])

        # Since the filename depending on time stamp, it wont match anyway
        for mis_match in report['mismatch_val']:
            for tar_key in mis_match['tar_key']:
                if tar_key == 'filename':
                    continue
                else:
                    self.assertEqual(report['mismatch_val'], [])
Example #29
0
    def test_main_process(self):
        """ Test simple case. """

        dyda_config = {
            'FaceMatchAnalyzer': {
                "pickle_path":
                '/home/shared/DT42/test_data/'
                'test_face_recognition/'
                'George/encodings.pickle'
            }
        }

        # initialization
        comp = FaceMatchAnalyzer(dyda_config_path=dyda_config)
        # run component
        comp.reset()
        comp.input_data = facematch_input
        comp.run()

        # compare output_data with reference

        ref_data = [{
            'size': {
                'height': -1,
                'width': -1
            },
            'folder':
            '',
            'filename':
            '',
            'annotations': [{
                'labinfo': {},
                'bottom': -1,
                'confidence': -1,
                'id': 0,
                'type': 'classification',
                'right': -1,
                'left': 0,
                'label': 'George',
                'top': 0
            }]
        }]
        tar_data = comp.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
        """ Test input is np.ndarray(not [np.ndarray]) case. """

        # initialization
        comp = FaceMatchAnalyzer(dyda_config_path=dyda_config)
        # run component
        comp.reset()
        comp.input_data = facematch_input[0]
        comp.run()

        # compare output_data with reference

        ref_data = {
            'size': {
                'height': -1,
                'width': -1
            },
            'folder':
            '',
            'filename':
            '',
            'annotations': [{
                'labinfo': {},
                'bottom': -1,
                'confidence': -1,
                'id': 0,
                'type': 'classification',
                'right': -1,
                'left': 0,
                'label': 'George',
                'top': 0
            }]
        }
        tar_data = comp.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
        """ Test input is [[np.ndarray, np.ndarray], [np.ndarray]] case. """

        # initialization
        comp = FaceMatchAnalyzer(dyda_config_path=dyda_config)
        # run component
        comp.reset()
        comp.input_data = [[facematch_input[0], facematch_input[0]],
                           [facematch_input[0]]]
        comp.run()

        # compare output_data with reference

        ref_data = {
            'size': {
                'height': -1,
                'width': -1
            },
            'folder':
            '',
            'filename':
            '',
            'annotations': [{
                'labinfo': {},
                'bottom': -1,
                'confidence': -1,
                'id': 0,
                'type': 'classification',
                'right': -1,
                'left': 0,
                'label': 'George',
                'top': 0
            }]
        }
        ref_datas = [[ref_data, ref_data], [ref_data]]
        tar_datas = comp.results

        for ref, tar in zip(ref_datas, tar_datas):
            report = dict_comparator.get_diff(ref, tar)
            self.assertEqual(report['extra_field'], [])
            self.assertEqual(report['missing_field'], [])
            self.assertEqual(report['mismatch_val'], [])
        """ Test case with specify tolerance. """

        dyda_config = {
            'FaceMatchAnalyzer': {
                "pickle_path":
                '/home/shared/DT42/test_data/'
                'test_face_recognition/'
                'George/encodings.pickle',
                "tolerance":
                0
            }
        }

        # initialization
        comp_t = FaceMatchAnalyzer(dyda_config_path=dyda_config)
        # run component
        comp_t.reset()
        comp_t.input_data = facematch_input
        comp_t.run()

        # compare output_data with reference

        ref_data = [{
            'size': {
                'height': -1,
                'width': -1
            },
            'folder':
            '',
            'filename':
            '',
            'annotations': [{
                'labinfo': {},
                'bottom': -1,
                'confidence': -1,
                'id': 0,
                'type': 'classification',
                'right': -1,
                'left': 0,
                'label': 'unknown',
                'top': 0
            }]
        }]
        tar_data = comp_t.results

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
Example #30
0
    def test_main_process(self):
        """ Test simple case. """

        ref_df = pd.DataFrame(
            index=['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max'],
            columns=['timestamps', 'longitude', 'latitude'])
        ref_df.loc[:, 'timestamps'] = [
            10, 1504232671658.5, 333895199.67643, 1504079020649,
            1504108965208.25, 1504144783533.5, 1504150772153.5, 1505180279414
        ]
        ref_df.loc[:, 'longitude'] = [
            10, -122.1669, 0.108751960391013, -122.332, -122.21025, -122.185,
            -122.067, -122.031
        ]
        ref_df.loc[:, 'latitude'] = [
            10, 47.5787, 0.029002107203137, 47.544, 47.55, 47.581, 47.60075,
            47.618
        ]

        dyda_config_StatAnalyzer_simple = {'StatAnalyzer': {}}

        # initialization
        comp = StatAnalyzer(dyda_config_path=dyda_config_StatAnalyzer_simple)
        # run component
        comp.reset()
        comp.input_data = input_df
        comp.run()

        # compare output_data with reference
        ref_data = ref_df

        # why I do not use pandas_data.df_to_lab_anno.
        # the reason is pandas_data.df_to_lab_anno using
        # df.to_dict("records"), and it will discard index
        # in the next test case I need to compare index
        ref_data = ref_data.to_dict('index')
        tar_data = comp.output_data
        tar_data = tar_data.to_dict('index')

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])
        """ Test case with specified object_col. """

        dyda_config_StatAnalyzer_object = {
            'StatAnalyzer': {
                "object_col": 'virtual_id'
            }
        }

        # initialization
        comp = StatAnalyzer(dyda_config_path=dyda_config_StatAnalyzer_object)
        # run component
        comp.reset()
        comp.input_data = input_df
        comp.run()

        # compare output_data with reference
        ref_data = ref_df.copy()
        uniques = \
            str(['284a38ab19acfe79b5a88b02e1d8'
                 '2699829b0153656a099f48f4a4d77064fb92'])
        ref_data.index = pd.MultiIndex.from_product([uniques, ref_data.index],
                                                    names=["stat of", None])

        ref_data = ref_data.to_dict('index')
        tar_data = comp.output_data
        tar_data = tar_data.to_dict('index')

        report = dict_comparator.get_diff(ref_data, tar_data)
        self.assertEqual(report['extra_field'], [])
        self.assertEqual(report['missing_field'], [])
        self.assertEqual(report['mismatch_val'], [])