Ejemplo n.º 1
0
    def test_yolo_tiny_portuguese(self):
        papermill.execute_notebook(
            "Experiment.ipynb",
            "/dev/null",
            parameters=dict(
                dataset=EXPERIMENT_DATASET,
                language="português",
                yolo_weight_type="tiny",
            ),
        )

        papermill.execute_notebook(
            "Deployment.ipynb",
            "/dev/null",
        )

        for ext in ['png', 'jpg']:

            data = datasets.image_testdata(kind='objects', ext=ext)

            with server.Server() as s:
                response = s.test(data=data, timeout=10)

            if 'tensor' in response.keys():
                tensor_shape = response["tensor"]['shape']

                self.assertEqual(tensor_shape[1], 6)  # outputs 6 features

            else:  # is a ndarray
                ndarray = response["ndarray"]

                self.assertEqual(len(ndarray[0]), 6)  # 6 features

            names = response["names"]
            self.assertEqual(len(names), 6)  # 6 feature names
Ejemplo n.º 2
0
    def test_yolo_empty_output(self):
        papermill.execute_notebook(
            "Experiment.ipynb",
            "/dev/null",
            parameters=dict(
                dataset=EXPERIMENT_DATASET,
                score_threshold=0.9999,
                iou_threshold=0.9999,
                yolo_weight_type="tiny",
            ),
        )

        papermill.execute_notebook(
            "Deployment.ipynb",
            "/dev/null",
        )

        data = datasets.image_testdata(kind='text', ext='png')

        with server.Server() as s:
            response = s.test(data=data, timeout=10)

        if 'tensor' in response.keys():
            tensor_shape = response["tensor"]['shape']

            self.assertEqual(tensor_shape[1], 6)  # outputs 6 features

        else:  # is a ndarray
            ndarray = response["ndarray"]

            self.assertEqual(len(ndarray[0]), 6)  # 6 features

        names = response["names"]
        self.assertEqual(len(names), 6)  # 6 feature names
Ejemplo n.º 3
0
    def test_experiment_ocr_output_data(self):
        papermill.execute_notebook(
            "Experiment.ipynb",
            "/dev/null",
            parameters=dict(
                dataset="/tmp/data/ocr_dataset.zip",
                target="target",
                filter_type="incluir",
                model_features="input_image",
                bbox_conf=60,
                segmentation_mode="Considere um único bloco de texto uniforme",
                ocr_engine="Mecanismo de redes neurais com apenas LSTM",
                language="por",
                bbox_return="np_array",
                image_return_format="N/A"),
        )

        papermill.execute_notebook(
            "Deployment.ipynb",
            "/dev/null",
        )

        for ext in ['png', 'jpg']:
            data = datasets.image_testdata(kind='text', ext=ext)

            with server.Server() as s:
                response = s.test(data=data, timeout=10)

            print(response)
            for bbox in response['ndarray']:
                xmin, ymin, xmax, ymax, text = bbox
                self.assertGreater(xmax, xmin, "BoundingBox incorreta.")
                self.assertGreater(ymax, ymin, "BoundingBox incorreta.")
Ejemplo n.º 4
0
    def test_experiment_face_detection_cuda(self):
        papermill.execute_notebook(
            "Experiment.ipynb",
            "/dev/null",
            parameters=dict(
                dataset="/tmp/data/football_teams.zip",
                device="cuda",
            ),
        )

        papermill.execute_notebook(
            "Deployment.ipynb",
            "/dev/null",
        )

        data = datasets.image_testdata(kind='people', ext='jpg')

        with server.Server() as s:
            response = s.test(data=data, timeout=10)

        if 'tensor' in response.keys():
            tensor_shape = response["tensor"]['shape']

            self.assertEqual(tensor_shape[1], 5)  # output 5 features

        else:  # is a ndarray
            ndarray = response["ndarray"]

            self.assertEqual(len(ndarray[0]), 5)  # 5 features

        names = response["names"]
        self.assertEqual(len(names), 5)  # 5 feature names
Ejemplo n.º 5
0
    def test_experiment_face_detection_without_people(self):
        papermill.execute_notebook(
            "Experiment.ipynb",
            "/dev/null",
            parameters=dict(
                dataset="/tmp/data/football_teams.zip",
                image_size=64,
                margin=5,
                min_face_size=10,
                factor=0.709,
                keep_all=True,
                device="cpu",
                seed=7,
                inference_batch_size=2,
                input_square_transformation_size=128,
            ),
        )

        papermill.execute_notebook(
            "Deployment.ipynb",
            "/dev/null",
        )

        for ext in ['png', 'jpg']:

            data = datasets.image_testdata(kind='objects', ext=ext)

            with server.Server() as s:
                response = s.test(data=data, timeout=10)

            if 'tensor' in response.keys():
                tensor_shape = response["tensor"]['shape']

                self.assertEqual(tensor_shape[1], 5)  # outputs 5 features

            else:  # is a ndarray
                ndarray = response["ndarray"]

                self.assertEqual(len(ndarray[0]), 5)  # 5 features

            names = response["names"]
            self.assertEqual(len(names), 5)  # 5 feature names