From faa6aeaa20cc52f3114811e302ca167cfbce7cd7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 14 Jun 2020 18:18:31 +1000 Subject: [PATCH 1/5] Fix pip requirements issues --- requirements.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 132881867491..fced686d6c5b 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ # pip install -U -r requirements.txt +Cython numpy==1.17 opencv-python torch >= 1.5 @@ -8,7 +9,8 @@ tqdm pillow tensorboard pyyaml - +torchvision +scipy # Nvidia Apex (optional) for mixed precision training -------------------------- # git clone https://github.com/NVIDIA/apex && cd apex && pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" . --user && cd .. && rm -rf apex From 34bf936ce641ab207a91d23ba48d402deb440b0b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 14 Jun 2020 18:18:57 +1000 Subject: [PATCH 2/5] Add more logging for diagnostics --- utils/datasets.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/utils/datasets.py b/utils/datasets.py index 456964ee1bea..a49e31e60090 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -261,6 +261,10 @@ def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, r try: path = str(Path(path)) # os-agnostic parent = str(Path(path).parent) + os.sep + + joined_path = os.path.join(os.getcwd(), parent) + print('Parent folder override for loading image files: %s' % (os.path.abspath(joined_path))) + if os.path.isfile(path): # file with open(path, 'r') as f: f = f.read().splitlines() @@ -274,7 +278,10 @@ def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, r raise Exception('Error loading data from %s. See %s' % (path, help_url)) n = len(self.img_files) + print('Loaded %g images' % (n)) assert n > 0, 'No images found in %s. See %s' % (path, help_url) + + bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index nb = bi[-1] + 1 # number of batches From f47ca2085c7a9b86c8e4620d89447e167ea02a60 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 14 Jun 2020 18:19:23 +1000 Subject: [PATCH 3/5] Include yolov5x extra large model weights --- weights/download_weights.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 weights/download_weights.sh diff --git a/weights/download_weights.sh b/weights/download_weights.sh old mode 100644 new mode 100755 index d799230fb993..6834ddb37bb2 --- a/weights/download_weights.sh +++ b/weights/download_weights.sh @@ -4,4 +4,5 @@ python3 -c "from utils.google_utils import *; attempt_download('weights/yolov5s.pt'); attempt_download('weights/yolov5m.pt'); -attempt_download('weights/yolov5l.pt')" +attempt_download('weights/yolov5l.pt'); +attempt_download('weights/yolov5x.pt')" From 13745819296ea0bace407d4003e666ace5b05818 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 14 Jun 2020 10:23:33 -0700 Subject: [PATCH 4/5] Update requirements.txt --- requirements.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index fced686d6c5b..d0d0c09ad31b 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,16 @@ # pip install -U -r requirements.txt Cython -numpy==1.17 +numpy opencv-python torch >= 1.5 matplotlib -pycocotools -tqdm pillow tensorboard pyyaml torchvision scipy +tqdm +'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI' # Nvidia Apex (optional) for mixed precision training -------------------------- # git clone https://github.com/NVIDIA/apex && cd apex && pip install -v --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" . --user && cd .. && rm -rf apex From 335c607a2469c2c2c5533bef891b289f72ac7ff7 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 14 Jun 2020 10:32:59 -0700 Subject: [PATCH 5/5] Update datasets.py --- utils/datasets.py | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index a49e31e60090..f3a5a4a7c721 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -261,10 +261,6 @@ def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, r try: path = str(Path(path)) # os-agnostic parent = str(Path(path).parent) + os.sep - - joined_path = os.path.join(os.getcwd(), parent) - print('Parent folder override for loading image files: %s' % (os.path.abspath(joined_path))) - if os.path.isfile(path): # file with open(path, 'r') as f: f = f.read().splitlines() @@ -278,10 +274,7 @@ def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, r raise Exception('Error loading data from %s. See %s' % (path, help_url)) n = len(self.img_files) - print('Loaded %g images' % (n)) assert n > 0, 'No images found in %s. See %s' % (path, help_url) - - bi = np.floor(np.arange(n) / batch_size).astype(np.int) # batch index nb = bi[-1] + 1 # number of batches @@ -298,20 +291,22 @@ def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, r 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]