def test_record_allocation_angle_type_with_zeros(self):
        data_set = DriveDataSet([
            FeedingData(None, 0.0),
            FeedingData(None, 0.1),
            FeedingData(None, -0.1),
            FeedingData(None, 0.25),
            FeedingData(None, -0.25),
            FeedingData(None, -1),
            FeedingData(None, 0.001),
            FeedingData(None, 0.251),
            FeedingData(None, -0.249),
        ])

        allocator = AngleSegmentRecordAllocator(
            data_set, AngleSegment((-1.0, -0.25), 10),
            AngleSegment((-0.25, -0.249), 10), AngleSegment((-0.249, -0.1),
                                                            10),
            AngleSegment((-0.1, 0), 10), AngleSegment((0, 0.001), 10),
            AngleSegment((0.001, 0.1), 10), AngleSegment((0.1, 0.25), 10),
            AngleSegment((0.25, 0.251), 10), AngleSegment((0.251, 1.001), 10),
            AngleSegment((1.001, 2.0), 10))
        records = allocator.allocate(any_number(), any_number(), len(data_set))
        self.assertEqual(same_range_angles(allocator, records, 0), [0.0])
        self.assertEqual(same_range_angles(allocator, records, 0.1), [0.1])
        self.assertEqual(same_range_angles(allocator, records, -0.1), [-0.1])
        self.assertEqual(same_range_angles(allocator, records, 0.25), [0.25])
        self.assertEqual(same_range_angles(allocator, records, -0.25), [-0.25])
        self.assertEqual(same_range_angles(allocator, records, 1), [0.251])
        self.assertEqual(same_range_angles(allocator, records, -1), [-1])
        self.assertEqual(same_range_angles(allocator, records, 0.001), [0.001])
        self.assertEqual(same_range_angles(allocator, records, -0.001), [-0.1])
        self.assertEqual(same_range_angles(allocator, records, 0.252), [0.251])
        self.assertEqual(same_range_angles(allocator, records, -0.249),
                         [-0.249])
Пример #2
0
def segment_normal_distribution_flip_brightness_shadow_reg():
    data_set_train, data_set_val = create_real_dataset(
        filter_method=drive_record_filter_include_all)

    # fine tune every part of training data so that make it meat std distrubtion
    allocator_train = AngleSegmentRecordAllocator(
        data_set_train,
        AngleSegment((-1.5, -0.5), 10),  # big sharp left
        AngleSegment((-0.5, -0.25), 14),  # sharp left
        AngleSegment((-0.25, -0.249),
                     0.5),  # sharp turn left (zero right camera)
        AngleSegment((-0.249, -0.1), 12),  # big turn left
        AngleSegment((-0.1, 0), 13),  # straight left
        AngleSegment((0, 0.001), 1),  # straight zero center camera
        AngleSegment((0.001, 0.1), 13),  # straight right
        AngleSegment((0.1, 0.25), 12),  # big turn right
        AngleSegment((0.25, 0.251),
                     0.5),  # sharp turn right (zero left camera)
        AngleSegment((0.251, 0.5), 14),  # sharp right
        AngleSegment((0.5, 1.5), 10)  # big sharp right
    )
    allocator_val = AngleSegmentRecordAllocator(
        data_set_val,
        AngleSegment((-1.5, -0.5), 10),  # big sharp left
        AngleSegment((-0.5, -0.25), 14),  # sharp left
        AngleSegment((-0.25, -0.249),
                     0.5),  # sharp turn left (zero right camera)
        AngleSegment((-0.249, -0.1), 12),  # big turn left
        AngleSegment((-0.1, 0), 13),  # straight left
        AngleSegment((0, 0.001), 1),  # straight zero center camera
        AngleSegment((0.001, 0.1), 13),  # straight right
        AngleSegment((0.1, 0.25), 12),  # big turn right
        AngleSegment((0.25, 0.251),
                     0.5),  # sharp turn right (zero left camera)
        AngleSegment((0.251, 0.5), 14),  # sharp right
        AngleSegment((0.5, 1.5), 10)  # big sharp right
    )

    # a pipe line with shift -> flip -> brightness -> shadow augment processes
    data_generator_train = DataGenerator(
        allocator_train.allocate,
        pipe_line_generators(flip_random_generator,
                             brightness_image_generator(0.35),
                             shadow_generator))
    data_generator_val = DataGenerator(
        allocator_val.allocate,
        pipe_line_generators(flip_random_generator,
                             brightness_image_generator(0.35),
                             shadow_generator))
    model = nvidia_with_regularizer(input_shape=data_set_train.output_shape(),
                                    dropout=0.2)
    Trainer(model,
            learning_rate=0.0001,
            epoch=450,
            multi_process=use_multi_process,
            custom_name="noshift").fit_generator(
                data_generator_train.generate(batch_size=256),
                data_generator_val.generate(batch_size=256))
Пример #3
0
    def test_angle_segment_pipe_line(self):
        data_set = self.create_real_dataset(
            filter_method=drive_record_filter_include_all)
        allocator = AngleSegmentRecordAllocator(
            data_set,
            AngleSegment((-1.5, -0.5), 10),  # big sharp left
            AngleSegment((-0.5, -0.25), 14),  # sharp left
            AngleSegment((-0.25, -0.249),
                         0.5),  # sharp turn left (zero right camera)
            AngleSegment((-0.249, -0.1), 12),  # big turn left
            AngleSegment((-0.1, 0), 13),  # straight left
            AngleSegment((0, 0.001), 1),  # straight zero center camera
            AngleSegment((0.001, 0.1), 13),  # straight right
            AngleSegment((0.1, 0.25), 12),  # big turn right
            AngleSegment((0.25, 0.251),
                         0.5),  # sharp turn right (zero left camera)
            AngleSegment((0.251, 0.5), 14),  # sharp right
            AngleSegment((0.5, 1.5), 10)  # big sharp right
        )

        # a pipe line with shift -> flip -> brightness -> shadow augment processes
        generator = pipe_line_generators(
            # shift_image_generator(angle_offset_pre_pixel=0.002),
            flip_random_generator,
            brightness_image_generator(0.35),
            shadow_generator)

        self._angle_distribution("angle_distribution_generator_angle_segment",
                                 100,
                                 256,
                                 allocator=allocator.allocate,
                                 generator=generator)
def segment_normal_distribution_shift_flip_brightness_shadow_reg():
    data_set = DriveDataSet.from_csv(
        "datasets/udacity-sample-track-1/driving_log.csv",
        crop_images=True,
        all_cameras_images=True,
        filter_method=drive_record_filter_include_all)
    # fine tune every part of training data so that make it meat std distrubtion
    allocator = AngleSegmentRecordAllocator(
        data_set,
        AngleSegment((-1.5, -0.5), 10),  # big sharp left
        AngleSegment((-0.5, -0.25), 14),  # sharp left
        AngleSegment((-0.25, -0.249),
                     3),  # sharp turn left (zero right camera)
        AngleSegment((-0.249, -0.1), 10),  # big turn left
        AngleSegment((-0.1, 0), 11),  # straight left
        AngleSegment((0, 0.001), 4),  # straight zero center camera
        AngleSegment((0.001, 0.1), 11),  # straight right
        AngleSegment((0.1, 0.25), 10),  # big turn right
        AngleSegment((0.25, 0.251), 3),  # sharp turn right (zero left camera)
        AngleSegment((0.251, 0.5), 14),  # sharp right
        AngleSegment((0.5, 1.5), 10)  # big sharp right
    )
    # a pipe line with shift -> flip -> brightness -> shadow augment processes
    augment = pipe_line_generators(
        shift_image_generator(angle_offset_pre_pixel=0.002), flip_generator,
        brightness_image_generator(0.35), shadow_generator)
    data_generator = DataGenerator(allocator.allocate, augment)
    model = nvidia_with_regularizer(input_shape=data_set.output_shape(),
                                    dropout=0.2)
    Trainer(model,
            learning_rate=0.0001,
            epoch=45,
            multi_process=use_multi_process,
            custom_name=inspect.stack()[0][3]).fit_generator(
                data_generator.generate(batch_size=256))