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

View File

@ -3,10 +3,10 @@
# New VM # New VM
rm -rf yolov3 weights coco rm -rf yolov3 weights coco
git clone https://github.com/ultralytics/yolov3 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 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/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 sudo shutdown
# Re-clone # Re-clone