コード例 #1
0
    def __init__(self, voc_root_dir, voc_dir_ls, voc_names, class_num, batch_size, anchors, width=608, height=608, data_debug=False):
        self.data_dirs = [path.join(path.join(voc_root_dir, voc_dir), "JPEGImages") for voc_dir in voc_dir_ls] 
        self.class_num = class_num  # classify number
        self.batch_size = batch_size
        self.anchors = np.asarray(anchors).astype(np.float32).reshape([-1, 2]) / [width, height]     #[9,2]
        print("anchors:\n", self.anchors)

        self.imgs_path = []
        self.labels_path = []

        self.num_batch = 0      # total batch number
        self.num_imgs = 0       # total number of images
        self.steps_per_epoch = 1

        self.data_debug = data_debug

        self.width = width
        self.height = height

        self.names_dict = tools.word2id(voc_names)    # dictionary of name to id

        # 初始化数据增强策略的参数
        self.flip_img = 0.5    # probility of flip image
        self.is_flip = False    # 
        self.gray_img = 0.02        # probility to gray picture
        self.smooth_delta = 0.001 # label smooth delta
        self.erase_img = 0        # probility of random erase some area
        self.gasuss = 0.0       # probility of gasuss noise

        self.__init_args()
コード例 #2
0
    def __init__(self, voc_root_dir, voc_dir_ls, voc_names, class_num, batch_size, anchors, multi_scale_img=True, width=608, height=608):
        self.data_dirs = [path.join(path.join(voc_root_dir, voc_dir), "JPEGImages") for voc_dir in voc_dir_ls]  # 数据文件路径
        self.class_num = class_num  # 分类数
        self.batch_size = batch_size
        self.anchors = np.asarray(anchors).astype(np.float32).reshape([-1, 2]) / [width, height]     #[9,2]
        print("anchors:\n", self.anchors)
        self.multi_scale_img = multi_scale_img  # 多尺度缩放图片

        self.imgs_path = []
        self.labels_path = []

        self.num_batch = 0      # 多少个 batch 了
        self.num_imgs = 0       # 一共多少张图片

        self.width = width
        self.height = height

        self.names_dict = tools.word2id(voc_names)    # 名字到 id 的字典

        # 初始化各项参数
        self.__init_args()
コード例 #3
0
ファイル: Data_voc.py プロジェクト: tecsai/YOLOv4_tensorflow
    def __init__(self,
                 voc_root_dir,
                 voc_dir_ls,
                 voc_names,
                 class_num,
                 batch_size,
                 anchors,
                 agument,
                 width=608,
                 height=608,
                 data_debug=False):
        self.data_dirs = [
            path.join(path.join(voc_root_dir, voc_dir), "JPEGImages")
            for voc_dir in voc_dir_ls
        ]  # 数据文件路径
        self.class_num = class_num  # 分类数
        self.batch_size = batch_size
        self.anchors = np.asarray(anchors).astype(np.float32).reshape(
            [-1, 2]) / [width, height]  #[9,2]
        print("anchors:\n", self.anchors)

        self.imgs_path = []
        self.labels_path = []

        self.num_batch = 0  # 多少个 batch 了
        self.num_imgs = 0  # 一共多少张图片

        self.data_debug = data_debug

        self.width = width
        self.height = height
        self.agument = agument  # data agument strategy

        self.smooth_delta = 0.01  # label smooth delta

        self.names_dict = tools.word2id(voc_names)  # 名字到 id 的字典

        # 初始化各项参数
        self.__init_args()
コード例 #4
0
ファイル: Data_voc.py プロジェクト: zhp7677/YOLOv4_tensorflow
    def __init__(self, voc_root_dir, voc_dir_ls, voc_names, class_num, batch_size, anchors, agument, width=608, height=608, data_debug=False):
        self.data_dirs = [path.join(path.join(voc_root_dir, voc_dir), "JPEGImages") for voc_dir in voc_dir_ls] 
        self.class_num = class_num  # classify number
        self.batch_size = batch_size
        self.anchors = np.asarray(anchors).astype(np.float32).reshape([-1, 2]) / [width, height]     #[9,2]
        print("anchors:\n", self.anchors)

        self.imgs_path = []
        self.labels_path = []

        self.num_batch = 0      # total batch number
        self.num_imgs = 0       # total number of images

        self.data_debug = data_debug

        self.width = width
        self.height = height
        self.agument = agument  # data agument strategy

        self.smooth_delta = 0.01 # label smooth delta

        self.names_dict = tools.word2id(voc_names)    # dictionary of name to id

        self.__init_args()
コード例 #5
0
    def __init__(self,
                 voc_root_dir,
                 voc_names_file,
                 class_num,
                 batch_size,
                 anchors,
                 is_tiny=False,
                 size=416):
        ''' 
        is_tiny:the flag that loading the yolo_tiny's data
        '''
        Log.add_log("message:voc_root_dir '" + str(voc_root_dir) +
                    "', batch_size '" + str(batch_size) + "', size '" +
                    str(size) + "'")
        self.data_dirs = [
            path.join(voc_dir, "JPEGImages") for voc_dir in voc_root_dir
        ]
        self.label_dirs = [
            path.join(voc_dir, "Annotations") for voc_dir in voc_root_dir
        ]
        self.class_num = class_num  # classify number
        self.batch_size = batch_size
        self.anchors = anchors
        self.debug_img = False  # show the image
        self.is_tiny = is_tiny  # load data of yolo_tiny

        self.imgs_path = []
        self.labels_path = []

        self.num_batch = 0  # total batch number
        self.num_imgs = 0  # total number of images

        self.size = size

        self.names_dict = tools.word2id(
            voc_names_file)  # dictionary of name to id

        self.steps_per_epoch = 1000

        # ################## data augment ##################
        self.flip = Flip()
        self.flip_img = 0.5  # probility of flip image

        self.gray_img = 0.1  # probility to gray picture

        self.label_smooth = 0.001  # label smooth delta

        # random erase
        self.erase = Erase(max_erase=5, max_w=30, max_h=30)
        self.erase_img = 0.5  # probility of random erase some area

        # color enhance
        self.color_enhance = Color_enhancement()

        # rotate : not use
        self.rotate_img = 0.0  # probility to rorate the image

        # translate
        self.translate = Translate(self.size, self.size, pad_thresh=30)
        self.trans_img = 0.5  # probility of translate the image

        self.gasuss = 0.0  # gasuss norse

        # initial all parameters
        self.__init_args()