From 58ae22058cfef8cde0dbf503ff9a74900bf6ef5f Mon Sep 17 00:00:00 2001 From: ManoleAlexandru99 Date: Sun, 16 Apr 2023 18:38:55 +0300 Subject: [PATCH] Semantic Segmentation with OG Img Resolution #0017 --- models/common.py | 7 ++++++- train.py | 2 +- utils/dataloaders.py | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/models/common.py b/models/common.py index 3131e2991156..a037ef82e7fa 100644 --- a/models/common.py +++ b/models/common.py @@ -851,10 +851,12 @@ class Seg(nn.Module): def __init__(self, in_channels): super().__init__() + print('SEG in channels: ', in_channels) self.cv1 = Conv(in_channels, 32, k=3) self.upsample = nn.Upsample(scale_factor=2, mode='nearest') self.cv2 = Conv(32, 64, k=3) - self.cv3 = Conv(64, 1, act=False) + self.cv3 = Conv(64, 64, k=3) + self.cv4 = Conv(64, 1, act=False) self.relu = nn.ReLU() # self.dropout_weak = nn.Dropout(0.25) @@ -873,8 +875,11 @@ def forward(self, x): # x = self.relu(x) # x = self.dropout_normal(x) x = self.cv3(x) + x = self.upsample(x) # print('----out shape', x.shape, '---\n') # x = self.sigmoid(x) + + x = self.cv4(x) return x diff --git a/train.py b/train.py index 25991bd25195..4bcff4fb22f3 100644 --- a/train.py +++ b/train.py @@ -550,7 +550,7 @@ def parse_opt(known=False): def main(opt, callbacks=Callbacks()): - print('\n---------- VERSION:', '#0016', '----------\n') + print('\n---------- VERSION:', '#0017', '----------\n') # Checks if RANK in {-1, 0}: print_args(vars(opt)) diff --git a/utils/dataloaders.py b/utils/dataloaders.py index f66c82e11416..a0e23d9320d0 100644 --- a/utils/dataloaders.py +++ b/utils/dataloaders.py @@ -677,7 +677,8 @@ def __getitem__(self, index): # Letterbox shape = self.batch_shapes[self.batch[index]] if self.rect else self.img_size # final letterboxed shape img, ratio, pad = letterbox(img, shape, auto=False, scaleup=self.augment) - mask_shape = [shape[0] // 2, shape[1] // 2] if self.rect else self.img_size // 2 + # mask_shape = [shape[0] // 2, shape[1] // 2] if self.rect else self.img_size // 2 + mask_shape = [shape[0], shape[1]] if self.rect else self.img_size seg, _, _ = letterbox(seg, mask_shape, auto=False, scaleup=self.augment, color=(0, 0, 0)) shapes = (h0, w0), ((h / h0, w / w0), pad) # for COCO mAP rescaling