getting this:
RuntimeError: Sizes of tensors must match except in dimension 2. Got 87 and 88 (The offending index is 0)
code is:
import numpy as np
from src.models.modnet import MODNet
from src.trainer import supervised_training_iter
import torchvision.transforms.functional as TF
import cv2
bs = 1 # batch size
lr = 0.01 # learn rate
epochs = 40 # total epochs
getting this: RuntimeError: Sizes of tensors must match except in dimension 2. Got 87 and 88 (The offending index is 0)
code is: import numpy as np from src.models.modnet import MODNet from src.trainer import supervised_training_iter import torchvision.transforms.functional as TF
import cv2
bs = 1 # batch size lr = 0.01 # learn rate epochs = 40 # total epochs
modnet = torch.nn.DataParallel(MODNet()).cuda() optimizer = torch.optim.SGD(modnet.parameters(), lr=lr, momentum=0.9) lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=int(0.25 * epochs), gamma=0.1)
image=Image.open("image/2.jpg") #input image trimap=Image.open("trimap/trimap.png") # trimap gt_matte=Image.open("gt/2.png") #ground truth
image = TF.totensor(image) image.unsqueeze(0) print(image.shape) trimap = TF.totensor(trimap) trimap.unsqueeze(0) gt_matte = TF.to_tensor(gt_matte) gtmatte.unsqueeze(0)
dataloader = CREATE_YOUR_DATALOADER(bs) # NOTE: please finish this function
for epoch in range(0, epochs):
for idx, (image, trimap, gt_matte) in enumerate(dataloader):
@ZHKKKe