From 512b518c2009373fd3d88c6419c0e853eeb0b42e Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 18 Jun 2020 12:39:33 -0700 Subject: [PATCH 01/17] update --bug-report.md --- .github/ISSUE_TEMPLATE/--bug-report.md | 34 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/--bug-report.md b/.github/ISSUE_TEMPLATE/--bug-report.md index 500b606b..392a125f 100644 --- a/.github/ISSUE_TEMPLATE/--bug-report.md +++ b/.github/ISSUE_TEMPLATE/--bug-report.md @@ -7,29 +7,43 @@ assignees: '' --- -Before submitting a bug report, please ensure that you are using the latest versions of: - - Python - - PyTorch - - This repository (run `git fetch && git status -uno` to check and `git pull` to update) +Before submitting a bug report, please be aware that your issue **must be reproducible** with all of the following, otherwise it is non-actionable, and we can not help you: + - **Current repository**: run `git fetch && git status -uno` to check and `git pull` to update your repo + - **Common dataset**: coco.yaml or coco128.yaml + - **Common environment**: Colab, Google Cloud, or Docker image. See https://github.com/ultralytics/yolov3#reproduce-our-environment -**Your issue must be reproducible on a public dataset (i.e COCO) using the latest version of the repository, and you must supply code to reproduce, or we can not help you.** - -If this is a custom training question we suggest you include your `train*.jpg`, `test*.jpg` and `results.png` figures. +If this is a custom dataset/training question you **must include** your `train*.jpg`, `test*.jpg` and `results.png` figures, or we can not help you. You can generate results.png with `utils.plot_results()`. ## 🐛 Bug A clear and concise description of what the bug is. -## To Reproduce -**REQUIRED**: Code to reproduce your issue below + +## To Reproduce (REQUIRED) + +Input: ``` -python train.py ... +import torch + +a = torch.tensor([5]) +c = a / 0 +``` + +Output: +``` +Traceback (most recent call last): + File "/Users/glennjocher/opt/anaconda3/envs/env1/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code + exec(code_obj, self.user_global_ns, self.user_ns) + File "", line 5, in + c = a / 0 +RuntimeError: ZeroDivisionError ``` ## Expected behavior A clear and concise description of what you expected to happen. + ## Environment If applicable, add screenshots to help explain your problem. From 9fd02ae22403c763f72a3dc7d1dd3d021bf158be Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 18 Jun 2020 12:40:26 -0700 Subject: [PATCH 02/17] update --bug-report.md --- .github/ISSUE_TEMPLATE/--bug-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/--bug-report.md b/.github/ISSUE_TEMPLATE/--bug-report.md index 392a125f..eb659a29 100644 --- a/.github/ISSUE_TEMPLATE/--bug-report.md +++ b/.github/ISSUE_TEMPLATE/--bug-report.md @@ -9,7 +9,7 @@ assignees: '' Before submitting a bug report, please be aware that your issue **must be reproducible** with all of the following, otherwise it is non-actionable, and we can not help you: - **Current repository**: run `git fetch && git status -uno` to check and `git pull` to update your repo - - **Common dataset**: coco.yaml or coco128.yaml + - **Common dataset**: coco2017.data or coco64.data - **Common environment**: Colab, Google Cloud, or Docker image. See https://github.com/ultralytics/yolov3#reproduce-our-environment If this is a custom dataset/training question you **must include** your `train*.jpg`, `test*.jpg` and `results.png` figures, or we can not help you. You can generate results.png with `utils.plot_results()`. From dc068369683adf831eba165c2760ba7fb3418456 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Thu, 18 Jun 2020 12:45:19 -0700 Subject: [PATCH 03/17] update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9e47c567..9da58e5a 100755 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ $ pip install -U -r requirements.txt ## Tutorials -* Open In Colab -* [Train Custom Data](https://github.com/ultralytics/yolov3/wiki/Train-Custom-Data) < highly recommended!! +* [Notebook](https://github.com/ultralytics/yolov3/blob/master/tutorial.ipynb) Open In Colab +* [Train Custom Data](https://github.com/ultralytics/yolov3/wiki/Train-Custom-Data) << highly recommended * [GCP Quickstart](https://github.com/ultralytics/yolov3/wiki/GCP-Quickstart) -* [Docker Quickstart Guide](https://github.com/ultralytics/yolov3/wiki/Docker-Quickstart) +* [Docker Quickstart Guide](https://github.com/ultralytics/yolov3/wiki/Docker-Quickstart) ![Docker Pulls](https://img.shields.io/docker/pulls/ultralytics/yolov3?logo=docker) * [A TensorRT Implementation of YOLOv3 and YOLOv4](https://github.com/wang-xinyu/tensorrtx/tree/master/yolov3-spp) From 10dc08f91b4ec4767aa971e2f750d9476185b8ea Mon Sep 17 00:00:00 2001 From: FuLin Date: Fri, 19 Jun 2020 12:54:57 -0400 Subject: [PATCH 04/17] revert value of gs back to 32(from 64) (#1317) --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index f963fdf1..ca99daca 100644 --- a/train.py +++ b/train.py @@ -64,7 +64,7 @@ def train(hyp): imgsz_min, imgsz_max, imgsz_test = opt.img_size # img sizes (min, max, test) # Image Sizes - gs = 64 # (pixels) grid size + gs = 32 # (pixels) grid size assert math.fmod(imgsz_min, gs) == 0, '--img-size %g must be a %g-multiple' % (imgsz_min, gs) opt.multi_scale |= imgsz_min != imgsz_max # multi if different (min, max) if opt.multi_scale: From 183e3833d2e931e4f8ff73f1e87f915bea6966d0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 20 Jun 2020 09:58:48 -0700 Subject: [PATCH 05/17] update datasets.py --- utils/datasets.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index 5811142a..c68e8660 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -18,7 +18,7 @@ from utils.utils import xyxy2xywh, xywh2xyxy help_url = 'https://github.com/ultralytics/yolov3/wiki/Train-Custom-Data' img_formats = ['.bmp', '.jpg', '.jpeg', '.png', '.tif', '.dng'] -vid_formats = ['.mov', '.avi', '.mp4'] +vid_formats = ['.mov', '.avi', '.mp4', '.mpg', '.mpeg', '.m4v', '.wmv', '.mkv'] # Get orientation exif tag for orientation in ExifTags.TAGS.keys(): @@ -63,7 +63,8 @@ class LoadImages: # for inference self.new_video(videos[0]) # new video else: self.cap = None - assert self.nF > 0, 'No images or videos found in ' + path + assert self.nF > 0, 'No images or videos found in %s. Supported formats are:\nimages: %s\nvideos: %s' % \ + (path, img_formats, vid_formats) def __iter__(self): self.count = 0 @@ -257,7 +258,7 @@ class LoadStreams: # multiple IP or RTSP cameras class LoadImagesAndLabels(Dataset): # for training/testing def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False, - cache_images=False, single_cls=False): + cache_images=False, single_cls=False, pad=0.0): try: path = str(Path(path)) # os-agnostic parent = str(Path(path).parent) + os.sep @@ -291,20 +292,22 @@ class LoadImagesAndLabels(Dataset): # for training/testing self.label_files = [x.replace('images', 'labels').replace(os.path.splitext(x)[-1], '.txt') for x in self.img_files] + # Read image shapes (wh) + sp = path.replace('.txt', '') + '.shapes' # shapefile path + try: + with open(sp, 'r') as f: # read existing shapefile + s = [x.split() for x in f.read().splitlines()] + assert len(s) == n, 'Shapefile out of sync' + except: + s = [exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')] + np.savetxt(sp, s, fmt='%g') # overwrites existing (if any) + + self.shapes = np.array(s, dtype=np.float64) + # Rectangular Training https://github.com/ultralytics/yolov3/issues/232 if self.rect: - # Read image shapes (wh) - sp = path.replace('.txt', '') + '.shapes' # shapefile path - try: - with open(sp, 'r') as f: # read existing shapefile - s = [x.split() for x in f.read().splitlines()] - assert len(s) == n, 'Shapefile out of sync' - except: - s = [exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')] - np.savetxt(sp, s, fmt='%g') # overwrites existing (if any) - # Sort by aspect ratio - s = np.array(s, dtype=np.float64) + s = self.shapes # wh ar = s[:, 1] / s[:, 0] # aspect ratio irect = ar.argsort() self.img_files = [self.img_files[i] for i in irect] @@ -322,7 +325,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing elif mini > 1: shapes[i] = [1, 1 / mini] - self.batch_shapes = np.ceil(np.array(shapes) * img_size / 64.).astype(np.int) * 64 + self.batch_shapes = np.ceil(np.array(shapes) * img_size / 32. + pad).astype(np.int) * 32 # Cache labels self.imgs = [None] * n @@ -530,7 +533,7 @@ def load_image(self, index): assert img is not None, 'Image Not Found ' + path h0, w0 = img.shape[:2] # orig hw r = self.img_size / max(h0, w0) # resize image to img_size - if r < 1 or (self.augment and r != 1): # always resize down, only resize up if training with augmentation + if r != 1: # always resize down, only resize up if training with augmentation interp = cv2.INTER_AREA if r < 1 and not self.augment else cv2.INTER_LINEAR img = cv2.resize(img, (int(w0 * r), int(h0 * r)), interpolation=interp) return img, (h0, w0), img.shape[:2] # img, hw_original, hw_resized From ca7794ed05dccda8d216b9f35ce335750788425c Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 20 Jun 2020 10:02:18 -0700 Subject: [PATCH 06/17] update test.py --- test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index ace09951..3e739d8e 100644 --- a/test.py +++ b/test.py @@ -23,6 +23,7 @@ def test(cfg, multi_label=True): # Initialize/load model and set device if model is None: + is_training = False device = torch_utils.select_device(opt.device, batch_size=batch_size) verbose = opt.task == 'test' @@ -47,6 +48,7 @@ def test(cfg, if device.type != 'cpu' and torch.cuda.device_count() > 1: model = nn.DataParallel(model) else: # called by train.py + is_training = True device = next(model.parameters()).device # get model device verbose = False @@ -61,7 +63,7 @@ def test(cfg, # Dataloader if dataloader is None: - dataset = LoadImagesAndLabels(path, imgsz, batch_size, rect=True, single_cls=opt.single_cls) + dataset = LoadImagesAndLabels(path, imgsz, batch_size, rect=True, single_cls=opt.single_cls, pad=0.5) batch_size = min(batch_size, len(dataset)) dataloader = DataLoader(dataset, batch_size=batch_size, @@ -91,7 +93,7 @@ def test(cfg, t0 += torch_utils.time_synchronized() - t # Compute loss - if hasattr(model, 'hyp'): # if model has loss hyperparameters + if is_training: # if model has loss hyperparameters loss += compute_loss(train_out, targets, model)[1][:3] # GIoU, obj, cls # Run NMS From a97f350461287daaabaac3200d90b7eec440453f Mon Sep 17 00:00:00 2001 From: Oulbacha Reda Date: Mon, 22 Jun 2020 16:15:40 -0400 Subject: [PATCH 07/17] Non-output layer freeze in train.py (#1333) Freeze layers that aren't of type YOLOLayer and that aren't the conv layers preceeding them --- train.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/train.py b/train.py index ca99daca..5abcacf0 100644 --- a/train.py +++ b/train.py @@ -143,6 +143,16 @@ def train(hyp): elif len(weights) > 0: # darknet format # possible weights are '*.weights', 'yolov3-tiny.conv.15', 'darknet53.conv.74' etc. load_darknet_weights(model, weights) + + if opt.freeze_layers: + output_layer_indices = [idx - 1 for idx, module in enumerate(model.module_list) \ + if isinstance(module, YOLOLayer)] + freeze_layer_indices = [x for x in range(len(model.module_list)) if\ + (x not in output_layer_indices) and \ + (x - 1 not in output_layer_indices)] + for idx in freeze_layer_indices: + for parameter in model.module_list[idx].parameters(): + parameter.requires_grad_(False) # Mixed precision training https://github.com/NVIDIA/apex if mixed_precision: @@ -394,6 +404,7 @@ if __name__ == '__main__': parser.add_argument('--device', default='', help='device id (i.e. 0 or 0,1 or cpu)') parser.add_argument('--adam', action='store_true', help='use adam optimizer') parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset') + parser.add_argument('--freeze-layers', action='store_true', help='Freeze non-output layers') opt = parser.parse_args() opt.weights = last if opt.resume else opt.weights check_git_status() From e276e3a1030a672fab6135c90a42f8b454713dc1 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 22 Jun 2020 15:20:08 -0700 Subject: [PATCH 08/17] Update greetings.yml --- .github/workflows/greetings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 2c5c5c70..860c4a26 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -16,7 +16,7 @@ jobs: - + To continue with this repo, please visit our [Custom Training Tutorial](https://github.com/ultralytics/yolov3/wiki/Train-Custom-Data) to get started, and see our [Google Colab Notebook](https://github.com/ultralytics/yolov3/blob/master/tutorial.ipynb), [Docker Image](https://hub.docker.com/r/ultralytics/yolov3), and [GCP Quickstart Guide](https://github.com/ultralytics/yolov3/wiki/GCP-Quickstart) for example environments. @@ -27,4 +27,4 @@ jobs: - **Edge AI** integrated into custom iOS and Android apps for realtime **30 FPS video inference.** - **Custom data training**, hyperparameter evolution, and model exportation to any destination. - For more information please visit https://www.ultralytics.com. \ No newline at end of file + For more information please visit https://www.ultralytics.com. From 8a414743e2fd92d2bc471c1f92281f82cf31bc10 Mon Sep 17 00:00:00 2001 From: Chang Lee Date: Mon, 22 Jun 2020 22:07:51 -0400 Subject: [PATCH 09/17] Fixed string format error during weight conversion (#1334) --- models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models.py b/models.py index 0323b25e..d5cfc02a 100755 --- a/models.py +++ b/models.py @@ -438,7 +438,7 @@ def convert(cfg='cfg/yolov3-spp.cfg', weights='weights/yolov3-spp.weights'): target = weights.rsplit('.', 1)[0] + '.pt' torch.save(chkpt, target) - print("Success: converted '%s' to 's%'" % (weights, target)) + print("Success: converted '%s' to '%s'" % (weights, target)) else: print('Error: extension not supported.') From a587d39cd447b85219e761734b5f1d5cb30197d8 Mon Sep 17 00:00:00 2001 From: NanoCode012 Date: Thu, 25 Jun 2020 01:37:09 +0700 Subject: [PATCH 10/17] Fixed train.py SyntaxError due to last commit (#1336) Fixed unexpected character after line continuation character on line 148,150, and 151 --- train.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/train.py b/train.py index 5abcacf0..705b5198 100644 --- a/train.py +++ b/train.py @@ -145,10 +145,9 @@ def train(hyp): load_darknet_weights(model, weights) if opt.freeze_layers: - output_layer_indices = [idx - 1 for idx, module in enumerate(model.module_list) \ - if isinstance(module, YOLOLayer)] - freeze_layer_indices = [x for x in range(len(model.module_list)) if\ - (x not in output_layer_indices) and \ + output_layer_indices = [idx - 1 for idx, module in enumerate(model.module_list) if isinstance(module, YOLOLayer)] + freeze_layer_indices = [x for x in range(len(model.module_list)) if + (x not in output_layer_indices) and (x - 1 not in output_layer_indices)] for idx in freeze_layer_indices: for parameter in model.module_list[idx].parameters(): From e1fb453079eea03f4da2b572abeab6d4dced9900 Mon Sep 17 00:00:00 2001 From: Jason Nataprawira <52592216+jas-nat@users.noreply.github.com> Date: Thu, 25 Jun 2020 20:09:41 +0700 Subject: [PATCH 11/17] Update requirements.txt (#1339) Add torchvision --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 08c696bb..7b631ebe 100755 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ numpy == 1.17 opencv-python >= 4.1 torch >= 1.5 +torchvision matplotlib pycocotools tqdm From 9b9715668c544f9fbb16bb95f6861cf73293d2e4 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 27 Jun 2020 09:09:02 -0700 Subject: [PATCH 12/17] add yolov4-tiny.cfg #1350 --- cfg/yolov4-tiny.cfg | 281 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 cfg/yolov4-tiny.cfg diff --git a/cfg/yolov4-tiny.cfg b/cfg/yolov4-tiny.cfg new file mode 100644 index 00000000..dc6f5bfb --- /dev/null +++ b/cfg/yolov4-tiny.cfg @@ -0,0 +1,281 @@ +[net] +# Testing +#batch=1 +#subdivisions=1 +# Training +batch=64 +subdivisions=1 +width=416 +height=416 +channels=3 +momentum=0.9 +decay=0.0005 +angle=0 +saturation = 1.5 +exposure = 1.5 +hue=.1 + +learning_rate=0.00261 +burn_in=1000 +max_batches = 500200 +policy=steps +steps=400000,450000 +scales=.1,.1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=2 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers=-1 +groups=2 +group_id=1 + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=32 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -1,-2 + +[convolutional] +batch_normalize=1 +filters=64 +size=1 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -6,-1 + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers=-1 +groups=2 +group_id=1 + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=64 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -1,-2 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -6,-1 + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers=-1 +groups=2 +group_id=1 + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=128 +size=3 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -1,-2 + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[route] +layers = -6,-1 + +[maxpool] +size=2 +stride=2 + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +################################## + +[convolutional] +batch_normalize=1 +filters=256 +size=1 +stride=1 +pad=1 +activation=leaky + +[convolutional] +batch_normalize=1 +filters=512 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + + + +[yolo] +mask = 3,4,5 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 +num=6 +jitter=.3 +scale_x_y = 1.05 +cls_normalizer=1.0 +iou_normalizer=0.07 +iou_loss=ciou +ignore_thresh = .7 +truth_thresh = 1 +random=0 +resize=1.5 +nms_kind=greedynms +beta_nms=0.6 + +[route] +layers = -4 + +[convolutional] +batch_normalize=1 +filters=128 +size=1 +stride=1 +pad=1 +activation=leaky + +[upsample] +stride=2 + +[route] +layers = -1, 23 + +[convolutional] +batch_normalize=1 +filters=256 +size=3 +stride=1 +pad=1 +activation=leaky + +[convolutional] +size=1 +stride=1 +pad=1 +filters=255 +activation=linear + +[yolo] +mask = 1,2,3 +anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319 +classes=80 +num=6 +jitter=.3 +scale_x_y = 1.05 +cls_normalizer=1.0 +iou_normalizer=0.07 +iou_loss=ciou +ignore_thresh = .7 +truth_thresh = 1 +random=0 +resize=1.5 +nms_kind=greedynms +beta_nms=0.6 From eadc06bce8d835fd1c1736898179fc3195d64520 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 27 Jun 2020 23:52:45 -0700 Subject: [PATCH 13/17] Update README.md --- README.md | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 9da58e5a..84ca6864 100755 --- a/README.md +++ b/README.md @@ -1,25 +1,7 @@ - - - - - - -
- - - - - - - - - -
+ + - -## Introduction - -The https://github.com/ultralytics/yolov3 repo contains inference and training code for YOLOv3 in PyTorch. The code works on Linux, MacOS and Windows. Training is done on the COCO dataset by default: https://cocodataset.org/#home. **Credit to Joseph Redmon for YOLO:** https://pjreddie.com/darknet/yolo/. +This repo contains Ultralytics inference and training code for YOLOv3 in PyTorch. The code works on Linux, MacOS and Windows. **Credit to Joseph Redmon for YOLO:** https://pjreddie.com/darknet/yolo/. ## Requirements From fc0394e0382fdefe3c73c13babf4980140a304b1 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 27 Jun 2020 23:54:46 -0700 Subject: [PATCH 14/17] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 84ca6864..b62dcad8 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ - - + + +  -This repo contains Ultralytics inference and training code for YOLOv3 in PyTorch. The code works on Linux, MacOS and Windows. **Credit to Joseph Redmon for YOLO:** https://pjreddie.com/darknet/yolo/. +This repo contains Ultralytics inference and training code for YOLOv3 in PyTorch. The code works on Linux, MacOS and Windows. Credit to Joseph Redmon for YOLO https://pjreddie.com/darknet/yolo/. ## Requirements From 46575cfad5fca621d1a4247b33dc581f822fe98a Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sat, 27 Jun 2020 23:59:54 -0700 Subject: [PATCH 15/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b62dcad8..bf4017d6 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ - +   This repo contains Ultralytics inference and training code for YOLOv3 in PyTorch. The code works on Linux, MacOS and Windows. Credit to Joseph Redmon for YOLO https://pjreddie.com/darknet/yolo/. From f8e5338f0a1e73e4a53bb0adba92eee38d8c0179 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 30 Jun 2020 16:19:56 -0700 Subject: [PATCH 16/17] --resume epochs update --- train.py | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/train.py b/train.py index 705b5198..5402f707 100644 --- a/train.py +++ b/train.py @@ -116,29 +116,35 @@ def train(hyp): attempt_download(weights) if weights.endswith('.pt'): # pytorch format # possible weights are '*.pt', 'yolov3-spp.pt', 'yolov3-tiny.pt' etc. - chkpt = torch.load(weights, map_location=device) + ckpt = torch.load(weights, map_location=device) # load model try: - chkpt['model'] = {k: v for k, v in chkpt['model'].items() if model.state_dict()[k].numel() == v.numel()} - model.load_state_dict(chkpt['model'], strict=False) + ckpt['model'] = {k: v for k, v in ckpt['model'].items() if model.state_dict()[k].numel() == v.numel()} + model.load_state_dict(ckpt['model'], strict=False) except KeyError as e: s = "%s is not compatible with %s. Specify --weights '' or specify a --cfg compatible with %s. " \ "See https://github.com/ultralytics/yolov3/issues/657" % (opt.weights, opt.cfg, opt.weights) raise KeyError(s) from e # load optimizer - if chkpt['optimizer'] is not None: - optimizer.load_state_dict(chkpt['optimizer']) - best_fitness = chkpt['best_fitness'] + if ckpt['optimizer'] is not None: + optimizer.load_state_dict(ckpt['optimizer']) + best_fitness = ckpt['best_fitness'] # load results - if chkpt.get('training_results') is not None: + if ckpt.get('training_results') is not None: with open(results_file, 'w') as file: - file.write(chkpt['training_results']) # write results.txt + file.write(ckpt['training_results']) # write results.txt - start_epoch = chkpt['epoch'] + 1 - del chkpt + # epochs + start_epoch = ckpt['epoch'] + 1 + if epochs < start_epoch: + print('%s has been trained for %g epochs. Fine-tuning for %g additional epochs.' % + (opt.weights, ckpt['epoch'], epochs)) + epochs += ckpt['epoch'] # finetune additional epochs + + del ckpt elif len(weights) > 0: # darknet format # possible weights are '*.weights', 'yolov3-tiny.conv.15', 'darknet53.conv.74' etc. @@ -349,17 +355,17 @@ def train(hyp): save = (not opt.nosave) or (final_epoch and not opt.evolve) if save: with open(results_file, 'r') as f: # create checkpoint - chkpt = {'epoch': epoch, + ckpt = {'epoch': epoch, 'best_fitness': best_fitness, 'training_results': f.read(), 'model': ema.ema.module.state_dict() if hasattr(model, 'module') else ema.ema.state_dict(), 'optimizer': None if final_epoch else optimizer.state_dict()} # Save last, best and delete - torch.save(chkpt, last) + torch.save(ckpt, last) if (best_fitness == fi) and not final_epoch: - torch.save(chkpt, best) - del chkpt + torch.save(ckpt, best) + del ckpt # end epoch ---------------------------------------------------------------------------------------------------- # end training From 63996a8bfe72e69da5f24c96cd4d3480e3beb737 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 30 Jun 2020 21:45:06 -0700 Subject: [PATCH 17/17] --resume update --- train.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/train.py b/train.py index 5402f707..5915848a 100644 --- a/train.py +++ b/train.py @@ -411,7 +411,7 @@ if __name__ == '__main__': parser.add_argument('--single-cls', action='store_true', help='train as single-class dataset') parser.add_argument('--freeze-layers', action='store_true', help='Freeze non-output layers') opt = parser.parse_args() - opt.weights = last if opt.resume else opt.weights + opt.weights = last if opt.resume and not opt.weights else opt.weights check_git_status() opt.cfg = check_file(opt.cfg) # check file opt.data = check_file(opt.data) # check file