diff --git a/requirements.txt b/requirements.txt index 132881867491..d0d0c09ad31b 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,16 @@ # pip install -U -r requirements.txt -numpy==1.17 +Cython +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 diff --git a/utils/datasets.py b/utils/datasets.py index 456964ee1bea..f3a5a4a7c721 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -291,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] 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')"