提交 b8557f87 authored 作者: Glenn Jocher's avatar Glenn Jocher

add stride to datasets.py

上级 3b062254
......@@ -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
......
......@@ -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,
......
......@@ -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
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论