dataset padding mode
This commit is contained in:
parent
eb97b2e413
commit
2a0aff685a
8
test.py
8
test.py
|
|
@ -56,8 +56,14 @@ def test(data,
|
||||||
|
|
||||||
# Dataloader
|
# Dataloader
|
||||||
if dataloader is None:
|
if dataloader is None:
|
||||||
|
fast |= conf_thres > 0.001 # enable fast mode
|
||||||
path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images
|
path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images
|
||||||
dataset = LoadImagesAndLabels(path, imgsz, batch_size, rect=True, single_cls=opt.single_cls)
|
dataset = LoadImagesAndLabels(path,
|
||||||
|
imgsz,
|
||||||
|
batch_size,
|
||||||
|
rect=True, # rectangular inference
|
||||||
|
single_cls=opt.single_cls, # single class mode
|
||||||
|
pad=0.0 if fast else 0.5) # padding
|
||||||
batch_size = min(batch_size, len(dataset))
|
batch_size = min(batch_size, len(dataset))
|
||||||
dataloader = DataLoader(dataset,
|
dataloader = DataLoader(dataset,
|
||||||
batch_size=batch_size,
|
batch_size=batch_size,
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ class LoadStreams: # multiple IP or RTSP cameras
|
||||||
|
|
||||||
class LoadImagesAndLabels(Dataset): # for training/testing
|
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,
|
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):
|
cache_images=False, single_cls=False, pad=0.0):
|
||||||
try:
|
try:
|
||||||
path = str(Path(path)) # os-agnostic
|
path = str(Path(path)) # os-agnostic
|
||||||
parent = str(Path(path).parent) + os.sep
|
parent = str(Path(path).parent) + os.sep
|
||||||
|
|
@ -322,7 +322,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
||||||
elif mini > 1:
|
elif mini > 1:
|
||||||
shapes[i] = [1, 1 / mini]
|
shapes[i] = [1, 1 / mini]
|
||||||
|
|
||||||
self.batch_shapes = np.round(np.array(shapes) * img_size / 32. + 1.).astype(np.int) * 32
|
self.batch_shapes = np.ceil(np.array(shapes) * img_size / 32. + pad).astype(np.int) * 32
|
||||||
|
|
||||||
# Cache labels
|
# Cache labels
|
||||||
self.imgs = [None] * n
|
self.imgs = [None] * n
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue