YOLOv6
YOLOv6 copied to clipboard
UNet+YOLO
When I am trying to add a few upsampling and downsampling layers before the Efficientrep backbone, I am facing the following issue.
ERROR in training steps. ERROR in training loop or eval/save model.
Training completed in 0.000 hours.
Traceback (most recent call last):
File "tools/train.py", line 112, in
Also this is the code for the UNet structure that I have incorporated.
import torch import torch.nn as nn import math from yolov6.layers.common import *
from .UNet_parts import *
def double_conv(in_channels, out_channels): return nn.Sequential( nn.Conv2d(in_channels, out_channels, 3, padding=1), nn.ReLU(inplace=True), nn.Conv2d(out_channels, out_channels, 3, padding=1), nn.ReLU(inplace=True) )
class UNet(nn.Module): def init( self, in_channels=3, channels_list=None, num_repeats= None, bilinear = None, ): super().init()
self.dconv_down1 = double_conv(in_channels, 64)
self.dconv_down2 = double_conv(64, 128)
self.dconv_down3 = double_conv(128, 256)
self.dconv_down4 = double_conv(256, 512)
self.maxpool = nn.MaxPool2d(2)
self.upsample = nn.Upsample(scale_factor=2, mode='bilinear', align_corners=True)
self.dconv_up3 = double_conv(256 , 256)
self.dconv_up2 = double_conv(128 , 128)
self.dconv_up1 = double_conv(128 , channels_list[0])
# self.conv_last = nn.Conv2d(64,channels_list[0], 1)
def forward(self, x):
conv1 = self.dconv_down1(x)
x = self.maxpool(conv1)
conv2 = self.dconv_down2(x)
x = self.maxpool(conv2)
conv3 = self.dconv_down3(x)
x = self.maxpool(conv3)
x = self.dconv_down4(x)
x = self.upsample(x)
x = torch.cat([x, conv3], dim=1)
x = self.dconv_up3(x)
x = self.upsample(x)
x = torch.cat([x, conv2], dim=1)
x = self.dconv_up2(x)
x = self.upsample(x)
x = torch.cat([x, conv1], dim=1)
out = self.dconv_up1(x)
# out = self.conv_last(x)
return out
Hi, please check the channels, the in channels of one conv should be the output channels of the previous layer.