You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello I am new to Computer Vision. I created a custom dataset instead of running the BddDataset and i am getting a runtime error as RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 20 but got size 19 for tensor number 1 in the list. what should i do to make this work?
the error seems to be from the concat function in common.py and when i outputted the shape of the 2 tensors it came as torch.Size([48, 256, 20, 26])
torch.Size([48, 256, 19, 25]). but i dont know what to do to make the shape compatible with each other. please help.
i am using an image of size 400 width and 300 height and have also set _C.MODEL.IMAGE_SIZE = [400, 300] # width * height, ex: 192 * 256 and _C.DATASET.ORG_IMG_SIZE = [300, 400]. could this be an issue since im not using an image size of 640*640
c:\yolop\yolop\tools\train.py:316: FutureWarning: torch.cuda.amp.GradScaler(args...) is deprecated. Please use torch.amp.GradScaler('cuda', args...) instead.
scaler = amp.GradScaler(enabled=device.type != 'cpu')
thr=0.25: 0.9996 best possible recall, 5.56 anchors past thr
n=9, img_size=300, metric_all=0.374/0.820-mean/best, past_thr=0.529-mean: 3,6, 4,9, 6,17, 10,12, 6,21, 14,32, 24,56, 46,101, 80,193
New anchors saved to model. Update model config to use these anchors in the future.
=> start training...
C:\YOLOP\YOLOP\lib\core\function.py:75: FutureWarning: torch.cuda.amp.autocast(args...) is deprecated. Please use torch.amp.autocast('cuda', args...) instead.
with amp.autocast(enabled=device.type != 'cpu'):
File ~.conda\envs\ashwin\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
exec_fun(compile(code_ast, filename, "exec"), globals)
File c:\yolop\yolop\coderunner.py:22
train.main()
File c:\yolop\yolop\tools\train.py:322 in main
train(cfg, train_loader, model, criterion, optimizer, scaler,
File C:\YOLOP\YOLOP\lib\core\function.py:76 in train
outputs = model(input)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1736 in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1747 in _call_impl
return forward_call(*args, **kwargs)
File C:\YOLOP\YOLOP\lib\models\YOLOP.py:555 in forward
x = block(x)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1736 in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1747 in _call_impl
return forward_call(*args, **kwargs)
File C:\YOLOP\YOLOP\lib\models\common.py:170 in forward
return torch.cat(x, self.d)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 20 but got size 19 for tensor number 1 in the list.
my configuration default file is as follows
C = CN()
_C.LOG_DIR = 'runs/'
_C.GPUS = (0,1)
_C.WORKERS = 8
_C.PIN_MEMORY = False
_C.PRINT_FREQ = 20
_C.AUTO_RESUME =False # Resume from the last training interrupt
_C.NEED_AUTOANCHOR = True # Re-select the prior anchor(k-means) When training from scratch (epoch=0), set it to be ture!
_C.DEBUG = False
_C.num_seg_class = 2
_C.LOSS = CN(new_allowed=True)
_C.LOSS.LOSS_NAME = ''
_C.LOSS.MULTI_HEAD_LAMBDA = None
_C.LOSS.FL_GAMMA = 0.0 # focal loss gamma
_C.LOSS.CLS_POS_WEIGHT = 1.0 # classification loss positive weights
_C.LOSS.OBJ_POS_WEIGHT = 1.0 # object loss positive weights
_C.LOSS.SEG_POS_WEIGHT = 1.0 # segmentation loss positive weights
_C.LOSS.BOX_GAIN = 0.05 # box loss gain
_C.LOSS.CLS_GAIN = 0.5 # classification loss gain
_C.LOSS.OBJ_GAIN = 1.0 # object loss gain
_C.LOSS.DA_SEG_GAIN = 0.2 # driving area segmentation loss gain
_C.LOSS.LL_SEG_GAIN = 0.2 # lane line segmentation loss gain
_C.LOSS.LL_IOU_GAIN = 0.2 # lane line iou loss gain
DATASET related params
_C.DATASET = CN(new_allowed=True)
_C.DATASET.DATAROOT = r"C:\YOLOP\YOLOP\BddDataset\images" # the path of images folder
_C.DATASET.LABELROOT = r"C:\YOLOP\YOLOP\BddDataset\det_annotations" # the path of det_annotations folder
_C.DATASET.MASKROOT = r"C:\YOLOP\YOLOP\BddDataset\ll_seg_annotations" # the path of da_seg_annotations folder
_C.DATASET.LANEROOT = r"C:\YOLOP\YOLOP\BddDataset\ll_seg_annotations" # the path of ll_seg_annotations folder
_C.DATASET.DATASET = 'BddDataset'
_C.DATASET.TRAIN_SET = 'train'
_C.DATASET.TEST_SET = 'val'
_C.DATASET.DATA_FORMAT = 'png'
_C.DATASET.SELECT_DATA = False
_C.DATASET.ORG_IMG_SIZE = [300, 400]
if training 3 tasks end-to-end, set all parameters as True
Alternating optimization
_C.TRAIN.SEG_ONLY = False # Only train two segmentation branchs
_C.TRAIN.DET_ONLY = False # Only train detection branch
_C.TRAIN.ENC_SEG_ONLY = False # Only train encoder and two segmentation branchs
_C.TRAIN.ENC_DET_ONLY = True # Only train encoder and detection branch
Single task
_C.TRAIN.DRIVABLE_ONLY = False # Only train da_segmentation task
_C.TRAIN.LANE_ONLY = False # Only train ll_segmentation task
_C.TRAIN.DET_ONLY = False # Only train detection task
Hello I am new to Computer Vision. I created a custom dataset instead of running the BddDataset and i am getting a runtime error as RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 20 but got size 19 for tensor number 1 in the list. what should i do to make this work?
the error seems to be from the concat function in common.py and when i outputted the shape of the 2 tensors it came as torch.Size([48, 256, 20, 26])
torch.Size([48, 256, 19, 25]). but i dont know what to do to make the shape compatible with each other. please help.
i am using an image of size 400 width and 300 height and have also set _C.MODEL.IMAGE_SIZE = [400, 300] # width * height, ex: 192 * 256 and _C.DATASET.ORG_IMG_SIZE = [300, 400]. could this be an issue since im not using an image size of 640*640
i have put _C.TRAIN.ENC_DET_ONLY = True
The complete log is as follows: -
%runcell -i 1 C:/YOLOP/YOLOP/coderunner.py
Starting the Operation...
Namespace(modelDir='', logDir='runs/', dataDir='', prevModelDir='', sync_bn=False, local_rank=-1, conf_thres=0.001, iou_thres=0.6)
AUTO_RESUME: False
CUDNN:
BENCHMARK: True
DETERMINISTIC: False
ENABLED: True
DATASET:
COLOR_RGB: False
DATAROOT: C:\YOLOP\YOLOP\BddDataset\images
DATASET: BddDataset
DATA_FORMAT: png
FLIP: True
HSV_H: 0.015
HSV_S: 0.7
HSV_V: 0.4
LABELROOT: C:\YOLOP\YOLOP\BddDataset\det_annotations
LANEROOT: C:\YOLOP\YOLOP\BddDataset\ll_seg_annotations
MASKROOT: C:\YOLOP\YOLOP\BddDataset\ll_seg_annotations
ORG_IMG_SIZE: [300, 400]
ROT_FACTOR: 10
SCALE_FACTOR: 0.25
SELECT_DATA: False
SHEAR: 0.0
TEST_SET: val
TRAIN_SET: train
TRANSLATE: 0.1
DEBUG: False
GPUS: (0, 1)
LOG_DIR: runs/
LOSS:
BOX_GAIN: 0.05
CLS_GAIN: 0.5
CLS_POS_WEIGHT: 1.0
DA_SEG_GAIN: 0.2
FL_GAMMA: 0.0
LL_IOU_GAIN: 0.2
LL_SEG_GAIN: 0.2
LOSS_NAME:
MULTI_HEAD_LAMBDA: None
OBJ_GAIN: 1.0
OBJ_POS_WEIGHT: 1.0
SEG_POS_WEIGHT: 1.0
MODEL:
EXTRA:
HEADS_NAME: ['']
IMAGE_SIZE: [400, 300]
NAME:
PRETRAINED:
PRETRAINED_DET:
STRU_WITHSHARE: False
NEED_AUTOANCHOR: True
PIN_MEMORY: False
PRINT_FREQ: 20
TEST:
BATCH_SIZE_PER_GPU: 24
MODEL_FILE:
NMS_CONF_THRESHOLD: 0.001
NMS_IOU_THRESHOLD: 0.6
PLOTS: True
SAVE_JSON: False
SAVE_TXT: False
TRAIN:
ANCHOR_THRESHOLD: 4.0
BATCH_SIZE_PER_GPU: 24
BEGIN_EPOCH: 0
DET_ONLY: False
DRIVABLE_ONLY: False
ENC_DET_ONLY: True
ENC_SEG_ONLY: False
END_EPOCH: 240
GAMMA1: 0.99
GAMMA2: 0.0
IOU_THRESHOLD: 0.2
LANE_ONLY: False
LR0: 0.001
LRF: 0.2
MOMENTUM: 0.937
NESTEROV: True
OPTIMIZER: adam
PLOT: True
SEG_ONLY: False
SHUFFLE: True
VAL_FREQ: 1
WARMUP_BIASE_LR: 0.1
WARMUP_EPOCHS: 3.0
WARMUP_MOMENTUM: 0.8
WD: 0.0005
WORKERS: 8
num_seg_class: 2
Using torch 2.5.1 CPU
freeze two Seg heads...
begin to bulid up model...
load model to device
torch.Size([1, 256, 8, 8])
torch.Size([1, 256, 8, 8])
torch.Size([1, 128, 16, 16])
torch.Size([1, 128, 16, 16])
torch.Size([1, 128, 8, 8])
torch.Size([1, 128, 8, 8])
torch.Size([1, 256, 4, 4])
torch.Size([1, 256, 4, 4])
freezing model.25.conv.weight
freezing model.25.bn.weight
freezing model.25.bn.bias
freezing model.27.cv1.conv.weight
freezing model.27.cv1.bn.weight
freezing model.27.cv1.bn.bias
freezing model.27.cv2.weight
freezing model.27.cv3.weight
freezing model.27.cv4.conv.weight
freezing model.27.cv4.bn.weight
freezing model.27.cv4.bn.bias
freezing model.27.bn.weight
freezing model.27.bn.bias
freezing model.27.m.0.cv1.conv.weight
freezing model.27.m.0.cv1.bn.weight
freezing model.27.m.0.cv1.bn.bias
freezing model.27.m.0.cv2.conv.weight
freezing model.27.m.0.cv2.bn.weight
freezing model.27.m.0.cv2.bn.bias
freezing model.28.conv.weight
freezing model.28.bn.weight
freezing model.28.bn.bias
freezing model.30.conv.weight
freezing model.30.bn.weight
freezing model.30.bn.bias
freezing model.31.cv1.conv.weight
freezing model.31.cv1.bn.weight
freezing model.31.cv1.bn.bias
freezing model.31.cv2.weight
freezing model.31.cv3.weight
freezing model.31.cv4.conv.weight
freezing model.31.cv4.bn.weight
freezing model.31.cv4.bn.bias
freezing model.31.bn.weight
freezing model.31.bn.bias
freezing model.31.m.0.cv1.conv.weight
freezing model.31.m.0.cv1.bn.weight
freezing model.31.m.0.cv1.bn.bias
freezing model.31.m.0.cv2.conv.weight
freezing model.31.m.0.cv2.bn.weight
freezing model.31.m.0.cv2.bn.bias
freezing model.33.conv.weight
freezing model.33.bn.weight
freezing model.33.bn.bias
freezing model.34.conv.weight
freezing model.34.bn.weight
freezing model.34.bn.bias
freezing model.36.cv1.conv.weight
freezing model.36.cv1.bn.weight
freezing model.36.cv1.bn.bias
freezing model.36.cv2.weight
freezing model.36.cv3.weight
freezing model.36.cv4.conv.weight
freezing model.36.cv4.bn.weight
freezing model.36.cv4.bn.bias
freezing model.36.bn.weight
freezing model.36.bn.bias
freezing model.36.m.0.cv1.conv.weight
freezing model.36.m.0.cv1.bn.weight
freezing model.36.m.0.cv1.bn.bias
freezing model.36.m.0.cv2.conv.weight
freezing model.36.m.0.cv2.bn.weight
freezing model.36.m.0.cv2.bn.bias
freezing model.37.conv.weight
freezing model.37.bn.weight
freezing model.37.bn.bias
freezing model.39.conv.weight
freezing model.39.bn.weight
freezing model.39.bn.bias
freezing model.40.cv1.conv.weight
freezing model.40.cv1.bn.weight
freezing model.40.cv1.bn.bias
freezing model.40.cv2.weight
freezing model.40.cv3.weight
freezing model.40.cv4.conv.weight
freezing model.40.cv4.bn.weight
freezing model.40.cv4.bn.bias
freezing model.40.bn.weight
freezing model.40.bn.bias
freezing model.40.m.0.cv1.conv.weight
freezing model.40.m.0.cv1.bn.weight
freezing model.40.m.0.cv1.bn.bias
freezing model.40.m.0.cv2.conv.weight
freezing model.40.m.0.cv2.bn.weight
freezing model.40.m.0.cv2.bn.bias
freezing model.42.conv.weight
freezing model.42.bn.weight
freezing model.42.bn.bias
begin to load data
building database...
100%|██████████| 52386/52386 [00:03<00:00, 15300.66it/s]
database build finish
building database...
100%|██████████| 14968/14968 [00:00<00:00, 17869.02it/s]
begin check anchors
database build finish
load data finished
WARNING: Extremely small objects found. 18112 of 111455 labels are < 3 pixels in width or height.
Running kmeans for 9 anchors on 111455 points...
thr=0.25: 0.9996 best possible recall, 5.40 anchors past thr
n=9, img_size=300, metric_all=0.369/0.813-mean/best, past_thr=0.533-mean: 3,6, 5,9, 6,16, 10,13, 6,22, 15,32, 27,59, 46,107, 85,208
Evolving anchors with Genetic Algorithm: fitness = 0.8197: 100%|██████████| 1000/1000 [00:02<00:00, 392.81it/s]
tensor([[[0.3128, 0.7526],
[0.4945, 1.0948],
[0.7666, 2.0700]],
c:\yolop\yolop\tools\train.py:316: FutureWarning:
torch.cuda.amp.GradScaler(args...)
is deprecated. Please usetorch.amp.GradScaler('cuda', args...)
instead.scaler = amp.GradScaler(enabled=device.type != 'cpu')
thr=0.25: 0.9996 best possible recall, 5.56 anchors past thr
n=9, img_size=300, metric_all=0.374/0.820-mean/best, past_thr=0.529-mean: 3,6, 4,9, 6,17, 10,12, 6,21, 14,32, 24,56, 46,101, 80,193
New anchors saved to model. Update model config to use these anchors in the future.
=> start training...
C:\YOLOP\YOLOP\lib\core\function.py:75: FutureWarning:
torch.cuda.amp.autocast(args...)
is deprecated. Please usetorch.amp.autocast('cuda', args...)
instead.with amp.autocast(enabled=device.type != 'cpu'):
torch.Size([48, 256, 20, 26])
torch.Size([48, 256, 19, 25])
Traceback (most recent call last):
File ~.conda\envs\ashwin\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
exec_fun(compile(code_ast, filename, "exec"), globals)
File c:\yolop\yolop\coderunner.py:22
train.main()
File c:\yolop\yolop\tools\train.py:322 in main
train(cfg, train_loader, model, criterion, optimizer, scaler,
File C:\YOLOP\YOLOP\lib\core\function.py:76 in train
outputs = model(input)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1736 in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1747 in _call_impl
return forward_call(*args, **kwargs)
File C:\YOLOP\YOLOP\lib\models\YOLOP.py:555 in forward
x = block(x)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1736 in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File ~.conda\envs\ashwin\Lib\site-packages\torch\nn\modules\module.py:1747 in _call_impl
return forward_call(*args, **kwargs)
File C:\YOLOP\YOLOP\lib\models\common.py:170 in forward
return torch.cat(x, self.d)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 20 but got size 19 for tensor number 1 in the list.
my configuration default file is as follows
C = CN()
_C.LOG_DIR = 'runs/'
_C.GPUS = (0,1)
_C.WORKERS = 8
_C.PIN_MEMORY = False
_C.PRINT_FREQ = 20
_C.AUTO_RESUME =False # Resume from the last training interrupt
_C.NEED_AUTOANCHOR = True # Re-select the prior anchor(k-means) When training from scratch (epoch=0), set it to be ture!
_C.DEBUG = False
_C.num_seg_class = 2
Cudnn related params
_C.CUDNN = CN()
_C.CUDNN.BENCHMARK = True
_C.CUDNN.DETERMINISTIC = False
_C.CUDNN.ENABLED = True
common params for NETWORK
_C.MODEL = CN(new_allowed=True)
_C.MODEL.NAME = ''
_C.MODEL.STRU_WITHSHARE = False #add share_block to segbranch
_C.MODEL.HEADS_NAME = ['']
_C.MODEL.PRETRAINED = ""
_C.MODEL.PRETRAINED_DET = ""
_C.MODEL.IMAGE_SIZE = [400, 300] # width * height, ex: 192 * 256
_C.MODEL.EXTRA = CN(new_allowed=True)
loss params
_C.LOSS = CN(new_allowed=True)
_C.LOSS.LOSS_NAME = ''
_C.LOSS.MULTI_HEAD_LAMBDA = None
_C.LOSS.FL_GAMMA = 0.0 # focal loss gamma
_C.LOSS.CLS_POS_WEIGHT = 1.0 # classification loss positive weights
_C.LOSS.OBJ_POS_WEIGHT = 1.0 # object loss positive weights
_C.LOSS.SEG_POS_WEIGHT = 1.0 # segmentation loss positive weights
_C.LOSS.BOX_GAIN = 0.05 # box loss gain
_C.LOSS.CLS_GAIN = 0.5 # classification loss gain
_C.LOSS.OBJ_GAIN = 1.0 # object loss gain
_C.LOSS.DA_SEG_GAIN = 0.2 # driving area segmentation loss gain
_C.LOSS.LL_SEG_GAIN = 0.2 # lane line segmentation loss gain
_C.LOSS.LL_IOU_GAIN = 0.2 # lane line iou loss gain
DATASET related params
_C.DATASET = CN(new_allowed=True)
_C.DATASET.DATAROOT = r"C:\YOLOP\YOLOP\BddDataset\images" # the path of images folder
_C.DATASET.LABELROOT = r"C:\YOLOP\YOLOP\BddDataset\det_annotations" # the path of det_annotations folder
_C.DATASET.MASKROOT = r"C:\YOLOP\YOLOP\BddDataset\ll_seg_annotations" # the path of da_seg_annotations folder
_C.DATASET.LANEROOT = r"C:\YOLOP\YOLOP\BddDataset\ll_seg_annotations" # the path of ll_seg_annotations folder
_C.DATASET.DATASET = 'BddDataset'
_C.DATASET.TRAIN_SET = 'train'
_C.DATASET.TEST_SET = 'val'
_C.DATASET.DATA_FORMAT = 'png'
_C.DATASET.SELECT_DATA = False
_C.DATASET.ORG_IMG_SIZE = [300, 400]
training data augmentation
_C.DATASET.FLIP = True
_C.DATASET.SCALE_FACTOR = 0.25
_C.DATASET.ROT_FACTOR = 10
_C.DATASET.TRANSLATE = 0.1
_C.DATASET.SHEAR = 0.0
_C.DATASET.COLOR_RGB = False
_C.DATASET.HSV_H = 0.015 # image HSV-Hue augmentation (fraction)
_C.DATASET.HSV_S = 0.7 # image HSV-Saturation augmentation (fraction)
_C.DATASET.HSV_V = 0.4 # image HSV-Value augmentation (fraction)
TODO: more augmet params to add
train
_C.TRAIN = CN(new_allowed=True)
_C.TRAIN.LR0 = 0.001 # initial learning rate (SGD=1E-2, Adam=1E-3)
_C.TRAIN.LRF = 0.2 # final OneCycleLR learning rate (lr0 * lrf)
_C.TRAIN.WARMUP_EPOCHS = 3.0
_C.TRAIN.WARMUP_BIASE_LR = 0.1
_C.TRAIN.WARMUP_MOMENTUM = 0.8
_C.TRAIN.OPTIMIZER = 'adam'
_C.TRAIN.MOMENTUM = 0.937
_C.TRAIN.WD = 0.0005
_C.TRAIN.NESTEROV = True
_C.TRAIN.GAMMA1 = 0.99
_C.TRAIN.GAMMA2 = 0.0
_C.TRAIN.BEGIN_EPOCH = 0
_C.TRAIN.END_EPOCH = 240
_C.TRAIN.VAL_FREQ = 1
_C.TRAIN.BATCH_SIZE_PER_GPU =24
_C.TRAIN.SHUFFLE = True
_C.TRAIN.IOU_THRESHOLD = 0.2
_C.TRAIN.ANCHOR_THRESHOLD = 4.0
if training 3 tasks end-to-end, set all parameters as True
Alternating optimization
_C.TRAIN.SEG_ONLY = False # Only train two segmentation branchs
_C.TRAIN.DET_ONLY = False # Only train detection branch
_C.TRAIN.ENC_SEG_ONLY = False # Only train encoder and two segmentation branchs
_C.TRAIN.ENC_DET_ONLY = True # Only train encoder and detection branch
Single task
_C.TRAIN.DRIVABLE_ONLY = False # Only train da_segmentation task
_C.TRAIN.LANE_ONLY = False # Only train ll_segmentation task
_C.TRAIN.DET_ONLY = False # Only train detection task
_C.TRAIN.PLOT = True #
testing
_C.TEST = CN(new_allowed=True)
_C.TEST.BATCH_SIZE_PER_GPU = 24
_C.TEST.MODEL_FILE = ''
_C.TEST.SAVE_JSON = False
_C.TEST.SAVE_TXT = False
_C.TEST.PLOTS = True
_C.TEST.NMS_CONF_THRESHOLD = 0.001
_C.TEST.NMS_IOU_THRESHOLD = 0.6
def update_config(cfg, args):
cfg.defrost()
# cfg.merge_from_file(args.cfg)
The text was updated successfully, but these errors were encountered: