Skip to content

Commit

Permalink
Semantic Segmentation with OG Img Resolution ultralytics#17
Browse files Browse the repository at this point in the history
  • Loading branch information
manole-alexandru committed Apr 16, 2023
1 parent 18e53b0 commit 58ae220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


Expand Down
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion utils/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 58ae220

Please sign in to comment.