This commit is contained in:
Glenn Jocher 2019-07-20 18:46:51 +02:00
parent bb80db54b7
commit 0448d1109f
1 changed files with 12 additions and 14 deletions

View File

@ -177,20 +177,18 @@ 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
s = np.array([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
dtype=np.float64) if not os.path.exists(sp): # read shapes using PIL and write shapefile for next time (faster)
# sp = 'data' + os.sep + path.replace('.txt', '.shapes').split(os.sep)[-1] # shapefile path s = [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) np.savetxt(sp, s, fmt='%g')
# 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
# try: s = np.array([x.split() for x in f.read().splitlines()], dtype=np.float64)
# with open(sp, 'r') as f: # read existing shapefile assert len(s) == n, 'Shapefile out of sync'
# s = np.array([x.split() for x in f.read().splitlines()], dtype=np.float64) except:
# assert len(s) == n, 'Shapefile out of sync' os.remove(sp)
# except: print('Shapefile deleted: %s. Please rerun again.' % sp)
# 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