From 5edb0ec40d596e6b3b0d6fd2fd7663ce7781a17f Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 12 Jun 2019 11:50:24 +0200 Subject: [PATCH] updates --- train.py | 12 +++++------- utils/datasets.py | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/train.py b/train.py index 50d29b5f..9b219254 100644 --- a/train.py +++ b/train.py @@ -64,7 +64,7 @@ def train( epochs=100, # 500200 batches at bs 4, 117263 images = 68 epochs batch_size=16, accumulate=4, # effective bs = 64 = batch_size * accumulate - multi_scale=False, + multi_scale=True, freeze_backbone=False, transfer=False # Transfer learning (train only YOLO layers) ): @@ -73,12 +73,13 @@ def train( latest = weights + 'latest.pt' best = weights + 'best.pt' device = torch_utils.select_device() + torch.backends.cudnn.benchmark = True # unsuitable for multiscale if multi_scale: - img_size = round((img_size / 32) * 1.5) * 32 # initiate with maximum multi_scale size + min_size = round(img_size / 32 / 1.5) + max_size = round(img_size / 32 * 1.5) + img_size = max_size * 32 # initiate with maximum multi_scale size # opt.num_workers = 0 # bug https://github.com/ultralytics/yolov3/issues/174 - else: - torch.backends.cudnn.benchmark = True # unsuitable for multiscale # Configure run data_dict = parse_data_cfg(data_cfg) @@ -244,10 +245,7 @@ def train( # Multi-Scale training (67% - 150%) every 10 batches if multi_scale and (i + 1) % 10 == 0: - min_size = round(img_size / 32 / 1.5) - max_size = round(img_size / 32 * 1.5) dataset.img_size = random.choice(range(min_size, max_size + 1)) * 32 - dataloader = DataLoader(dataset, batch_size=batch_size, num_workers=opt.num_workers, diff --git a/utils/datasets.py b/utils/datasets.py index c8d23395..6ad6c564 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -153,6 +153,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing replace('.bmp', '.txt'). replace('.png', '.txt') for x in self.img_files] + multi_scale = False if multi_scale: s = img_size / 32 self.multi_scale = ((np.linspace(0.5, 1.5, nb) * s).round().astype(np.int) * 32)