Skip to content

Commit

Permalink
Merge pull request ultralytics#16 from Laughing-q/instance_seg
Browse files Browse the repository at this point in the history
clean up
  • Loading branch information
AyushExel committed Aug 11, 2022
2 parents 146d968 + a24b3fd commit a271758
Show file tree
Hide file tree
Showing 22 changed files with 1,587 additions and 3,259 deletions.
617 changes: 0 additions & 617 deletions evaluator.py

This file was deleted.

25 changes: 6 additions & 19 deletions models/yolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
from copy import deepcopy
from pathlib import Path

from torch import NoneType

FILE = Path(__file__).resolve()
ROOT = FILE.parents[1] # YOLOv5 root directory
if str(ROOT) not in sys.path:
Expand All @@ -30,7 +28,6 @@
from utils.plots import feature_visualization
from utils.torch_utils import (fuse_conv_and_bn, initialize_weights, model_info, profile, scale_img, select_device,
time_sync)
import torch.nn.functional as F

try:
import thop # for FLOPs computation
Expand Down Expand Up @@ -110,8 +107,7 @@ def __init__(self, nc=80, anchors=(), mask_dim=32, proto_channel=256, ch=(), inp
# nn.SiLU(inplace=True),
# nn.Conv2d(self.proto_c, self.proto_c, kernel_size=3, stride=1, padding=1),
# nn.SiLU(inplace=True),
# nn.Upsample(scale_factor=2, mode='nearest'),
Upsample(scale_factor=2, mode='bilinear', align_corners=False),
nn.Upsample(scale_factor=2, mode='bilinear', align_corners=False),
nn.Conv2d(self.proto_c, self.proto_c, kernel_size=3, stride=1, padding=1),
nn.SiLU(inplace=True),
nn.Conv2d(self.proto_c, self.mask_dim, kernel_size=1, padding=0),
Expand Down Expand Up @@ -279,7 +275,10 @@ def _initialize_biases(self, cf=None): # initialize biases into Detect(), cf is
for mi, s in zip(m.m, m.stride): # from
b = mi.bias.view(m.na, -1) # conv.bias(255) to (3,85)
b.data[:, 4] += math.log(8 / (640 / s) ** 2) # obj (8 objects per 640 image)
b.data[:, 5+m.mask_dim:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
if hasattr(m, "mask_dim"):
b.data[:, 5+m.mask_dim:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
else:
b.data[:, 5:] += math.log(0.6 / (m.nc - 0.99)) if cf is None else torch.log(cf / cf.sum()) # cls
mi.bias = torch.nn.Parameter(b.view(-1), requires_grad=True)

def _print_biases(self):
Expand Down Expand Up @@ -379,18 +378,6 @@ def parse_model(d, ch): # model_dict, input_channels(3)
ch.append(c2)
return nn.Sequential(*layers), sorted(save)

class Upsample(nn.Module):
'''
deterministic upsample layer
'''
def __init__(self, scale_factor, mode="bilinear", align_corners=False) -> None:
super().__init__()
self.scale_factor = scale_factor
self.mode = mode
self.align_corners = align_corners

def forward(self, x):
return F.interpolate(x, scale_factor=self.scale_factor, mode=self.mode, align_corners=self.align_corners)

if __name__ == '__main__':
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -424,4 +411,4 @@ def forward(self, x):
print(f'Error in {cfg}: {e}')

else: # report fused model summary
model.fuse()
model.fuse()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ scipy>=1.4.1
torch>=1.7.0
torchvision>=0.8.1
tqdm>=4.64.0
easydict>=1.9
protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012

# Logging -------------------------------------
Expand Down
287 changes: 0 additions & 287 deletions seg_augmentations.py

This file was deleted.

0 comments on commit a271758

Please sign in to comment.