This commit is contained in:
Glenn Jocher 2019-07-20 18:31:58 +02:00
parent 0ed0b354ee
commit bb80db54b7
2 changed files with 16 additions and 14 deletions

View File

@ -177,18 +177,20 @@ class LoadImagesAndLabels(Dataset): # for training/testing
# Rectangular Training https://github.com/ultralytics/yolov3/issues/232
if self.rect:
# Read image shapes
sp = 'data' + os.sep + path.replace('.txt', '.shapes').split(os.sep)[-1] # shapefile path
if not os.path.exists(sp): # read shapes using PIL and write shapefile for next time (faster)
s = [exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')]
np.savetxt(sp, s, fmt='%g')
try:
with open(sp, 'r') as f: # read existing shapefile
s = np.array([x.split() for x in f.read().splitlines()], dtype=np.float64)
assert len(s) == n, 'Shapefile out of sync'
except:
os.remove(sp)
print('Shapefile deleted: %s. Please rerun again.' % sp)
s = np.array([exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')],
dtype=np.float64)
# sp = 'data' + os.sep + path.replace('.txt', '.shapes').split(os.sep)[-1] # shapefile path
# if not os.path.exists(sp): # read shapes using PIL and write shapefile for next time (faster)
# s = [exif_size(Image.open(f)) for f in tqdm(self.img_files, desc='Reading image shapes')]
# np.savetxt(sp, s, fmt='%g')
#
# try:
# with open(sp, 'r') as f: # read existing shapefile
# s = np.array([x.split() for x in f.read().splitlines()], dtype=np.float64)
# assert len(s) == n, 'Shapefile out of sync'
# except:
# os.remove(sp)
# print('Shapefile deleted: %s. Please rerun again.' % sp)
# Sort by aspect ratio
ar = s[:, 1] / s[:, 0] # aspect ratio

View File

@ -3,10 +3,10 @@
# New VM
rm -rf yolov3 weights coco
git clone https://github.com/ultralytics/yolov3
git clone https://github.com/cocodataset/cocoapi && cd cocoapi/PythonAPI && make && cd ../.. && cp -r cocoapi/PythonAPI/pycocotools yolov3
# git clone https://github.com/cocodataset/cocoapi && cd cocoapi/PythonAPI && make && cd ../.. && cp -r cocoapi/PythonAPI/pycocotools yolov3
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
bash yolov3/weights/download_yolov3_weights.sh && cp -r weights yolov3
bash yolov3/data/get_coco_dataset.sh
bash yolov3/data/get_coco_dataset_gdrive.sh
sudo shutdown
# Re-clone