Exemplo n.º 1
0
def assert_aug_pipelines(aug_pipelines: List[Pipeline]):
    try:
        assert all(isinstance(o, Pipeline) for o in aug_pipelines)
    except:
        raise Exception(
            "Each augmentation pipeline needs to be an instance of Pipeline.")
    try:
        assert all(pipe.split_idx == 0 for pipe in aug_pipelines)
    except:
        raise Exception(
            "Each Pipeline instance need to set to Pipeline(..., split_idx=0)")
    def __init__(self,
                 c_targ_x,
                 c_targ_y,
                 base_dir,
                 targ_dir,
                 world,
                 img_dir=None,
                 show_freq=0,
                 abs_base_dir=0):
        self.c_targ_x = c_targ_x
        self.c_targ_y = c_targ_y
        self.base_dir = base_dir
        self.targ_dir = targ_dir

        self.prev_targ_angle = 0

        self.world = world
        self.curr_x = self.world.x()
        self.curr_y = self.world.y()

        self.direction = 0
        self.update_direction()

        self.dist = math.inf
        self.update_dist()

        self.angle = 0
        self.step = math.inf

        self.all_angles = np.array([])
        self.all_base_angles = np.array([])

        self.abs_base_dir = abs_base_dir

        self.left_throttle = 0
        self.right_throttle = 0

        self.img_dir = img_dir
        if self.img_dir != None:
            stack_conds = []
            stack_conds.append(os.path.isdir(os.path.join(img_dir, "left")))
            stack_conds.append(os.path.isdir(os.path.join(img_dir, "right")))
            stack_conds.append(os.path.isdir(os.path.join(img_dir,
                                                          "straight")))

            # if subdirectories exist, then stacking method not used
            if all(stack_conds):
                self.img_num_l = len(os.listdir(os.path.join(img_dir, "left")))
                self.img_num_r = len(os.listdir(os.path.join(img_dir,
                                                             "right")))
                self.img_num_s = len(
                    os.listdir(os.path.join(img_dir, "straight")))
                self.stack_dir = False
            else:
                self.img_num = len(os.listdir(img_dir))
                self.stack_dir = True

        self.show_freq = show_freq
Exemplo n.º 3
0
 def _check_kernel_size_consistency(kernel_size):
     if not (isinstance(kernel_size, tuple) or
             (isinstance(kernel_size, list)
              and all([isinstance(elem, tuple) for elem in kernel_size]))):
         raise ValueError('`kernel_size` must be tuple or list of tuples')