updates
This commit is contained in:
parent
a8f443518f
commit
4156e83319
|
@ -26,6 +26,10 @@ data/*
|
|||
!data/coco.data
|
||||
!data/coco_*.data
|
||||
!data/coco_*.txt
|
||||
!data/coco_*.txt
|
||||
!data/trainvalno5k.shapes
|
||||
!data/5k.shapes
|
||||
|
||||
|
||||
pycocotools/*
|
||||
results*.txt
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -150,12 +150,17 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
|||
nb = bi[-1] + 1 # number of batches
|
||||
from PIL import Image
|
||||
|
||||
# Read image aspect ratios
|
||||
iter = tqdm(self.img_files, desc='Reading image shapes') if n > 100 else self.img_files
|
||||
s = np.array([Image.open(f).size for f in iter])
|
||||
ar = s[:, 1] / s[:, 0] # aspect ratio
|
||||
# Read image shapes
|
||||
sp = 'data' + os.sep + path.replace('.txt', '.shapes').split(os.sep)[-1] # shapefile path
|
||||
if os.path.exists(sp): # read existing shapefile
|
||||
with open(sp, 'r') as f:
|
||||
s = np.array([x.split() for x in f.read().splitlines()], dtype=np.float32)
|
||||
else: # no shapefile, so read shape using PIL and write shapefile for next time (faster)
|
||||
s = np.array([Image.open(f).size for f in tqdm(self.img_files, desc='Reading image shapes')])
|
||||
np.savetxt(sp, s, fmt='%g')
|
||||
|
||||
# Sort by aspect ratio
|
||||
ar = s[:, 1] / s[:, 0] # aspect ratio
|
||||
i = ar.argsort()
|
||||
ar = ar[i]
|
||||
self.img_files = [self.img_files[i] for i in i]
|
||||
|
|
Loading…
Reference in New Issue