예제 #1
0
 def setUp(self):
     with zipfile.ZipFile("./Ressources/MidAir.zip", "r") as zip_ref:
         zip_ref.extractall("./Ressources")
     self.processor = MidAirDataPreprocessor("./Ressources/MidAir")
     self.processor.clean()
     data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
     data_segmenter.segment((4, ), 0)
예제 #2
0
    def test_segment_givenSingleSegmentLength_shouldProduceFixedLengthSegments(
            self):
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        data_segmenter.segment((4, ), 0)
        sensor_records = h5py.File(
            "./Ressources/MidAir/Kite_test/cloudy/sensor_records.hdf5", "r+")

        for trajectory in sensor_records:
            dataframe = pd.DataFrame(
                sensor_records[trajectory]["trajectory_segments"],
                columns=["sequence_length", "start_frame_index"])
            expected_length = len(
                list(
                    range(
                        0,
                        data_segmenter._get_trajectory_length(
                            sensor_records[trajectory]) - 4, 4)))

            self.assertEqual(len(dataframe), expected_length)

            expected_start_Frame_index = 0
            for i, row in dataframe.iterrows():
                self.assertEqual(row["sequence_length"], 4)
                self.assertEqual(row["start_frame_index"],
                                 expected_start_Frame_index)
                expected_start_Frame_index += 4
예제 #3
0
    def test_givenDataset_when_no_trajectories_specified_should_map_all_segments(
            self):
        # re-segment so that 1 trajectory equals 1 segment
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        data_segmenter.segment()

        dataset = MidAirImageSequenceDataset("./Ressources/MidAir/Kite_test",
                                             new_size=(512, 512))

        self.assertEqual(dataset.__len__(), 5)
예제 #4
0
    def setUp(self):
        with zipfile.ZipFile("./Ressources/MidAir.zip", "r") as zip_ref:
            zip_ref.extractall("./Ressources")

        self.processor = MidAirDataPreprocessor(
            "./Ressources/MidAir/Kite_test/")
        self.processor.clean()
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test/")
        # segment so that 1 trajectory equals 1 segment
        data_segmenter.segment()

        self.sensor_record = h5py.File(
            "./Ressources/MidAir/Kite_test/cloudy/sensor_records.hdf5", "r+")
예제 #5
0
    def setUp(self):
        with zipfile.ZipFile("./Ressources/MidAir.zip", "r") as zip_ref:
            zip_ref.extractall("./Ressources")
        self.processor = MidAirDataPreprocessor("./Ressources/MidAir")
        self.processor.clean()
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        data_segmenter.segment((4, ), 0)

        self.dataset: MidAirImageSequenceDataset = MidAirImageSequenceDataset(
            "./Ressources/MidAir/Kite_test",
            new_size=(512, 512),
            img_mean=(1, 1, 1))
        self.second_segment: Segment = self.dataset._get_segment(1)
예제 #6
0
    def test_given_sensor_record_when_trajectories_specified_should_map_segments_of_specified_trajectories_only(
            self):
        # re-segment so that 1 trajectory equals 1 segment
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        data_segmenter.segment()

        dataset = MidAirImageSequenceDataset(
            "./Ressources/MidAir/Kite_test",
            new_size=(512, 512),
            trajectories=["trajectory_3000", "trajectory_3001"])

        self.assertEqual(dataset.__len__(), 2)
        for i in range(0, dataset.__len__()):
            self.assertTrue(
                dataset._get_segment(i).trajectory in
                ["trajectory_3000", "trajectory_3001"])
예제 #7
0
    def test_segment_when_resegmenting_should_overwrite_segment(self):
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        # first segmentation
        data_segmenter.segment((4, ), 0)
        # second segmentation
        data_segmenter.segment((6, ), 0)
        sensor_records = h5py.File(
            "./Ressources/MidAir/Kite_test/cloudy/sensor_records.hdf5", "r+")

        for trajectory in sensor_records:
            dataframe = pd.DataFrame(
                sensor_records[trajectory]["trajectory_segments"],
                columns=["sequence_length", "start_frame_index"])
            expected_length = len(
                list(
                    range(
                        0,
                        data_segmenter._get_trajectory_length(
                            sensor_records[trajectory]) - 6, 6)))

            self.assertEqual(len(dataframe), expected_length)

            expected_start_Frame_index = 0
            for i, row in dataframe.iterrows():
                self.assertEqual(row["sequence_length"], 6)
                self.assertEqual(row["start_frame_index"],
                                 expected_start_Frame_index)
                expected_start_Frame_index += 6
예제 #8
0
    def test_segment_givenNoneSegmentLength_shouldSegmentWillBeTrajectory(
            self):
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        data_segmenter.segment(None)
        sensor_records = h5py.File(
            "./Ressources/MidAir/Kite_test/cloudy/sensor_records.hdf5", "r+")

        for trajectory in sensor_records:
            dataframe = pd.DataFrame(
                sensor_records[trajectory]["trajectory_segments"],
                columns=["sequence_length", "start_frame_index"])
            expected_length = 1
            self.assertEqual(len(dataframe), expected_length)

            for i, row in dataframe.iterrows():
                self.assertEqual(
                    row["sequence_length"],
                    data_segmenter._get_trajectory_length(
                        sensor_records[trajectory]))
                self.assertEqual(row["start_frame_index"], 0)
예제 #9
0
    def test_segment_givenRangeSegmentLength_shouldProduceVariableLengthSegments(
            self):
        data_segmenter = MidAirDataSegmenter("./Ressources/MidAir/Kite_test")
        data_segmenter.segment((2, 4), 0)
        sensor_records = h5py.File(
            "./Ressources/MidAir/Kite_test/cloudy/sensor_records.hdf5", "r+")

        for trajectory in sensor_records:
            dataframe = pd.DataFrame(
                sensor_records[trajectory]["trajectory_segments"],
                columns=["sequence_length", "start_frame_index"])

            self.assertTrue(3 in dataframe["sequence_length"])
            self.assertTrue(4 in dataframe["sequence_length"])
            self.assertTrue(2 in dataframe["sequence_length"])

            expected_start_Frame_index = 0
            for i, row in dataframe.iterrows():
                self.assertTrue(row["sequence_length"] <= 4
                                or row["sequence_length"] >= 2)
                self.assertEqual(row["start_frame_index"],
                                 expected_start_Frame_index)
                expected_start_Frame_index += row["sequence_length"]
예제 #10
0
def segment_midair(param: Parameters):
    print("Segmenting the MidAir dataset")
    train_data_segmenter = MidAirDataSegmenter(param.midair_training_path)
    train_data_segmenter.segment(param.seq_len, overlap=param.overlap)
    valid_data_segmenter = MidAirDataSegmenter(param.midair_validation_path)
    valid_data_segmenter.segment(param.seq_len, overlap=param.overlap)
    test_data_segmenter = MidAirDataSegmenter(param.midair_test_path)
    test_data_segmenter.segment((param.sliding_window_size, ),
                                overlap=param.sliding_window_overlap)