diff --git a/fluid/PaddleCV/yolov3/data_utils.py b/fluid/PaddleCV/yolov3/data_utils.py index ac022593119e0008c3f7f3858303cbf5bc717650..c43e040af8d46f0fc57ee9862da4ee749768e7c6 100644 --- a/fluid/PaddleCV/yolov3/data_utils.py +++ b/fluid/PaddleCV/yolov3/data_utils.py @@ -124,7 +124,7 @@ class GeneratorEnqueuer(object): for thread in self._threads: if self._use_multiprocessing: if thread.is_alive(): - thread.terminate() + thread.join(timeout) else: thread.join(timeout) if self._manager: diff --git a/fluid/PaddleCV/yolov3/image_utils.py b/fluid/PaddleCV/yolov3/image_utils.py index 6933721e88a413c69769ae27a24821064c450ad6..a35e20be71fe10cce2c4629cb64ea4c5e74cfe27 100644 --- a/fluid/PaddleCV/yolov3/image_utils.py +++ b/fluid/PaddleCV/yolov3/image_utils.py @@ -154,7 +154,7 @@ def random_expand(img, gtboxes, max_ratio=4., fill=None, keep_ratio=True, thresh def shuffle_gtbox(gtbox, gtlabel, gtscore): gt = np.concatenate([gtbox, gtlabel[:, np.newaxis], gtscore[:, np.newaxis]], axis=1) - idx = np.arange(gt.shape[1]) + idx = np.arange(gt.shape[0]) np.random.shuffle(idx) gt = gt[idx, :] return gt[:, :4], gt[:, 4], gt[:, 5] diff --git a/fluid/PaddleCV/yolov3/models/yolov3.py b/fluid/PaddleCV/yolov3/models/yolov3.py index b28c14bdb6afe302eea967f54cf6c3f2624824f2..9ea4ef4433bb647967c4c6ef4160bc6ab491bd61 100644 --- a/fluid/PaddleCV/yolov3/models/yolov3.py +++ b/fluid/PaddleCV/yolov3/models/yolov3.py @@ -134,7 +134,6 @@ class YOLOv3(object): anchor_mask = cfg.anchor_masks[i] if self.is_train: - ignore_thresh = float(self.ignore_thresh) loss = fluid.layers.yolov3_loss( x=out, gtbox=self.gtbox, diff --git a/fluid/PaddleCV/yolov3/reader.py b/fluid/PaddleCV/yolov3/reader.py index 5d37402d004bd3346a76b3fe3ff7fd521571e619..1f3ce3545d8b27c2ea14168cdaf1958bce563703 100644 --- a/fluid/PaddleCV/yolov3/reader.py +++ b/fluid/PaddleCV/yolov3/reader.py @@ -250,10 +250,11 @@ dsr = DataSetReader() def train(size=416, batch_size=64, shuffle=True, + total_iter=0, mixup_iter=0, random_sizes=[], - num_workers=12, - max_queue=36, + num_workers=8, + max_queue=32, use_multiprocessing=True): generator = dsr.get_reader('train', size, batch_size, shuffle, int(mixup_iter/num_workers), random_sizes) @@ -266,6 +267,7 @@ def train(size=416, yield data def reader(): + cnt = 0 try: enqueuer = GeneratorEnqueuer( infinite_reader(), use_multiprocessing=use_multiprocessing) @@ -279,6 +281,10 @@ def train(size=416, else: time.sleep(0.02) yield generator_out + cnt += 1 + if cnt >= total_iter: + enqueuer.stop() + return generator_out = None finally: if enqueuer is not None: diff --git a/fluid/PaddleCV/yolov3/train.py b/fluid/PaddleCV/yolov3/train.py index f3ac6e3e3c0d6ede424f7c5cfa1b15fd3642254a..07f74a545c3cbd5047e3304a609d2bafe159a2d7 100644 --- a/fluid/PaddleCV/yolov3/train.py +++ b/fluid/PaddleCV/yolov3/train.py @@ -86,8 +86,9 @@ def train(): if cfg.random_shape: random_sizes = [32 * i for i in range(10, 20)] - mixup_iter = cfg.max_iter - cfg.start_iter - cfg.no_mixup_iter - train_reader = reader.train(input_size, batch_size=cfg.batch_size, shuffle=True, mixup_iter=mixup_iter*devices_num, random_sizes=random_sizes, use_multiprocessing=cfg.use_multiprocess) + total_iter = cfg.max_iter - cfg.start_iter + mixup_iter = total_iter - cfg.no_mixup_iter + train_reader = reader.train(input_size, batch_size=cfg.batch_size, shuffle=True, total_iter=total_iter*devices_num, mixup_iter=mixup_iter*devices_num, random_sizes=random_sizes, use_multiprocessing=cfg.use_multiprocess) py_reader = model.py_reader py_reader.decorate_paddle_reader(train_reader)