Explorar el Código

add stride to datasets.py

5.0
Glenn Jocher hace 4 años
padre
commit
b8557f87e3
Se han modificado 3 ficheros con 7 adiciones y 4 borrados
  1. +1
    -0
      test.py
  2. +4
    -2
      train.py
  3. +2
    -2
      utils/datasets.py

+ 1
- 0
test.py Ver fichero

@@ -73,6 +73,7 @@ def test(data,
batch_size,
rect=True, # rectangular inference
single_cls=opt.single_cls, # single class mode
stride=int(max(model.stride)), # model stride
pad=0.5) # padding
batch_size = min(batch_size, len(dataset))
nw = min([os.cpu_count(), batch_size if batch_size > 1 else 0, 8]) # number of workers

+ 4
- 2
train.py Ver fichero

@@ -160,7 +160,8 @@ def train(hyp):
hyp=hyp, # augmentation hyperparameters
rect=opt.rect, # rectangular training
cache_images=opt.cache_images,
single_cls=opt.single_cls)
single_cls=opt.single_cls,
stride=gs)
mlc = np.concatenate(dataset.labels, 0)[:, 0].max() # max label class
assert mlc < nc, 'Label class %g exceeds nc=%g in %s. Correct your labels or your model.' % (mlc, nc, opt.cfg)

@@ -179,7 +180,8 @@ def train(hyp):
hyp=hyp,
rect=True,
cache_images=opt.cache_images,
single_cls=opt.single_cls),
single_cls=opt.single_cls,
stride=gs),
batch_size=batch_size,
num_workers=nw,
pin_memory=True,

+ 2
- 2
utils/datasets.py Ver fichero

@@ -258,7 +258,7 @@ class LoadStreams: # multiple IP or RTSP cameras

class LoadImagesAndLabels(Dataset): # for training/testing
def __init__(self, path, img_size=416, batch_size=16, augment=False, hyp=None, rect=False, image_weights=False,
cache_images=False, single_cls=False, pad=0.0):
cache_images=False, single_cls=False, stride=32, pad=0.0):
try:
path = str(Path(path)) # os-agnostic
parent = str(Path(path).parent) + os.sep
@@ -325,7 +325,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
elif mini > 1:
shapes[i] = [1, 1 / mini]

self.batch_shapes = np.ceil(np.array(shapes) * img_size / 32. + pad).astype(np.int) * 32
self.batch_shapes = np.ceil(np.array(shapes) * img_size / stride + pad).astype(np.int) * stride

# Cache labels
self.imgs = [None] * n

Cargando…
Cancelar
Guardar