Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding polygon detection alongside bounding boxes #6506

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
202e62e
adding polygon yolo
Jan 25, 2022
ca9d901
last changes
Jan 27, 2022
6ad3f30
more cleaning
Jan 27, 2022
2dd00f1
added polygon_train bool to parse model
Jan 27, 2022
2d61899
modifying detect for yolo and polygon
Jan 28, 2022
9e8f8ed
polygon plot results
Jan 28, 2022
1828e48
dataset fix
Jan 31, 2022
6fb367d
merging latest yolo commits
Jan 31, 2022
2754448
Delete lpr.yaml
ahmad4633 Jan 31, 2022
6be048b
cleaning
Jan 31, 2022
218a731
last changes
Feb 2, 2022
38d936c
Merge remote-tracking branch 'origin/master' into test/polygon_yolo
Feb 2, 2022
3e16e13
fixing polygon_create_dataloader
Feb 2, 2022
3e974f2
fixing plot_results
Feb 2, 2022
bb7026a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 2, 2022
ce3527b
Update requirements.txt
ahmad4633 Feb 2, 2022
fc6aa18
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 2, 2022
6f10192
Update detect.py
ahmad4633 Feb 2, 2022
183e2d3
fixing indents
ahmad4633 Feb 4, 2022
66a53f0
Merge remote-tracking branch 'origin/master' into test/polygon_yolo
ahmad4633 Feb 4, 2022
3f30d43
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2022
7d077d5
pre-commit.ci
ahmad4633 Feb 4, 2022
b0282f9
Merge branch 'test/polygon_yolo' of https://github.com/ahmad4633/yolo…
ahmad4633 Feb 4, 2022
7de5778
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 4, 2022
bdb0994
solving conflicts
ahmad4633 Feb 5, 2022
03235fb
Merge branch 'test/polygon_yolo' of https://github.com/ahmad4633/yolo…
ahmad4633 Feb 5, 2022
8385766
Merge branch 'master' into test/polygon_yolo
ahmad4633 Feb 5, 2022
957cf53
fixing ppe8
ahmad4633 Feb 7, 2022
4de79d1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 7, 2022
f6ef69d
fixing pep8
ahmad4633 Feb 7, 2022
66a5401
Merge branch 'test/polygon_yolo' of https://github.com/ahmad4633/yolo…
ahmad4633 Feb 7, 2022
f832fa3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 7, 2022
c114834
pep8 fixes
ahmad4633 Feb 7, 2022
80a5afd
Merge branch 'test/polygon_yolo' of https://github.com/ahmad4633/yolo…
ahmad4633 Feb 7, 2022
f52af58
pep8 fixes
ahmad4633 Feb 7, 2022
e15e5ad
plots_polygon.py:167: [F841] local variable 'c' is assigned to but ne…
ahmad4633 Feb 7, 2022
a6f385c
pep8 fix indents
ahmad4633 Feb 7, 2022
6b8e102
Update setup.py
ahmad4633 Feb 7, 2022
607bfec
fixing export
ahmad4633 Feb 14, 2022
85fcc88
Merge branch 'master' into test/polygon_yolo
ahmad4633 Feb 14, 2022
ded4625
Merge branch 'master' into test/polygon_yolo
ahmad4633 Feb 14, 2022
1101845
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 14, 2022
4dd66aa
pre commit fix
ahmad4633 Feb 14, 2022
e50fb5a
Merge branch 'test/polygon_yolo' of https://github.com/ahmad4633/yolo…
ahmad4633 Feb 14, 2022
410a8d2
fixed name 'MixConv2d' is not defined
ahmad4633 Feb 15, 2022
5cc70b6
adding polygon_load_image
ahmad4633 Feb 15, 2022
efb59a4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
last changes
  • Loading branch information
ata authored and ata committed Jan 27, 2022
commit ca9d9018eb5fd45558e3fabd1594c49d92c23580
21 changes: 21 additions & 0 deletions data/lpr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# PASCAL VOC dataset http://host.robots.ox.ac.uk/pascal/VOC/
# Train command: python train.py --data voc.yaml
# Default dataset location is next to /yolov5:
# /parent_folder
# /VOC
# /yolov5


# download command/URL (optional)
download: bash data/scripts/get_voc.sh

# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
train: D:/Datasets/Board/small/train # 16551 images
val: D:/Datasets/Board/small/val # 16551 images
#val: /ssd_1t/derron/yolov5-face/data/widerface/train/ # 4952 images

# number of classes
nc: 1

# class names
names: ['front']
File renamed without changes.
48 changes: 0 additions & 48 deletions models/polygon_yolov5m.yaml

This file was deleted.

24 changes: 12 additions & 12 deletions models/polygon_yolov5l.yaml → models/polygon_yolov5n.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
# parameters
nc: 80 # number of classes
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # layer channel multiple
# YOLOv5 🚀 by Ultralytics, GPL-3.0 license

# anchors
# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.25 # layer channel multiple
anchors:
- [10,13, 16,30, 33,23] # P3/8
- [30,61, 62,45, 59,119] # P4/16
- [116,90, 156,198, 373,326] # P5/32

# YOLOv5 backbone
# YOLOv5 v6.0 backbone
backbone:
# [from, number, module, args]
[[-1, 1, Focus, [64, 3]], # 0-P1/2
[[-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, C3, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 9, C3, [256]],
[-1, 6, C3, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, C3, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 1, SPP, [1024, [5, 9, 13]]],
[-1, 3, C3, [1024, False]], # 9
[-1, 3, C3, [1024]],
[-1, 1, SPPF, [1024, 5]], # 9
]

# YOLOv5 head
# YOLOv5 v6.0 head
head:
[[-1, 1, Conv, [512, 1, 1]],
[-1, 1, nn.Upsample, [None, 2, 'nearest']],
Expand All @@ -44,5 +44,5 @@ head:
[[-1, 10], 1, Concat, [1]], # cat head P5
[-1, 3, C3, [1024, False]], # 23 (P5/32-large)

[[17, 20, 23], 1, Polygon_Detect, [nc, anchors]], # Polygon_Detect(P3, P4, P5)
[[17, 20, 23], 1, Polygon_Detect, [nc, anchors]], # Detect(P3, P4, P5)
]
56 changes: 0 additions & 56 deletions models/polygon_yolov5s copy.yaml

This file was deleted.

56 changes: 0 additions & 56 deletions models/polygon_yolov5s_ucas copy.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions models/polygon_yolov5x.yaml

This file was deleted.

64 changes: 32 additions & 32 deletions models/yolo_polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
sys.path.append(Path(__file__).parent.parent.absolute().__str__()) # to run '$ python *.py' files in subdirectories
logger = logging.getLogger(__name__)

from models.common import *
from utils.general_polygon import polygon_non_max_suppression, polygon_scale_coords
from utils.plots_polygon import polygon_plot_one_box

from models.yolo import *
from models.experimental import *
from utils.autoanchor_polygon import check_anchor_order
Expand Down Expand Up @@ -42,8 +46,8 @@ def polygon_parse_model(d, ch): # model_dict, input_channels(3)
pass

n = max(round(n * gd), 1) if n > 1 else n # depth gain
if m in [Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, DWConv, MixConv2d, Focus, CrossConv, BottleneckCSP,
C3, C3TR]:
if m in [Conv, GhostConv, Bottleneck, GhostBottleneck, SPP, SPPF, DWConv, MixConv2d, Focus, CrossConv,
BottleneckCSP, C3, C3TR, C3SPP, C3Ghost]:
c1, c2 = ch[f], args[0]
if c2 != no: # if not output
c2 = make_divisible(c2 * gw, 8)
Expand Down Expand Up @@ -222,10 +226,6 @@ def autoshape(self): # add Polygon_AutoShape module
copy_attr(m, self, include=('yaml', 'nc', 'hyp', 'names', 'stride'), exclude=()) # copy attributes
return m

from models.common import *
from utils.general_polygon import polygon_non_max_suppression, polygon_scale_coords
from utils.plots_polygon import polygon_plot_one_box

# Ancillary functions with polygon anchor boxes-------------------------------------------------------------------------------------------

class Polygon_NMS(nn.Module):
Expand Down Expand Up @@ -392,32 +392,32 @@ def __len__(self):
return self.n


class GhostConv(nn.Module):
# Ghost Convolution https://github.com/huawei-noah/ghostnet
def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups
super(GhostConv, self).__init__()
c_ = c2 // 2 # hidden channels
self.cv1 = Conv(c1, c_, k, s, None, g, act)
self.cv2 = Conv(c_, c_, 5, 1, None, c_, act)

def forward(self, x):
y = self.cv1(x)
return torch.cat([y, self.cv2(y)], 1)


class GhostBottleneck(nn.Module):
# Ghost Bottleneck https://github.com/huawei-noah/ghostnet
def __init__(self, c1, c2, k=3, s=1): # ch_in, ch_out, kernel, stride
super(GhostBottleneck, self).__init__()
c_ = c2 // 2
self.conv = nn.Sequential(GhostConv(c1, c_, 1, 1), # pw
DWConv(c_, c_, k, s, act=False) if s == 2 else nn.Identity(), # dw
GhostConv(c_, c2, 1, 1, act=False)) # pw-linear
self.shortcut = nn.Sequential(DWConv(c1, c1, k, s, act=False),
Conv(c1, c2, 1, 1, act=False)) if s == 2 else nn.Identity()

def forward(self, x):
return self.conv(x) + self.shortcut(x)
# class GhostConv(nn.Module):
# # Ghost Convolution https://github.com/huawei-noah/ghostnet
# def __init__(self, c1, c2, k=1, s=1, g=1, act=True): # ch_in, ch_out, kernel, stride, groups
# super(GhostConv, self).__init__()
# c_ = c2 // 2 # hidden channels
# self.cv1 = Conv(c1, c_, k, s, None, g, act)
# self.cv2 = Conv(c_, c_, 5, 1, None, c_, act)

# def forward(self, x):
# y = self.cv1(x)
# return torch.cat([y, self.cv2(y)], 1)


# class GhostBottleneck(nn.Module):
# # Ghost Bottleneck https://github.com/huawei-noah/ghostnet
# def __init__(self, c1, c2, k=3, s=1): # ch_in, ch_out, kernel, stride
# super(GhostBottleneck, self).__init__()
# c_ = c2 // 2
# self.conv = nn.Sequential(GhostConv(c1, c_, 1, 1), # pw
# DWConv(c_, c_, k, s, act=False) if s == 2 else nn.Identity(), # dw
# GhostConv(c_, c2, 1, 1, act=False)) # pw-linear
# self.shortcut = nn.Sequential(DWConv(c1, c1, k, s, act=False),
# Conv(c1, c2, 1, 1, act=False)) if s == 2 else nn.Identity()

# def forward(self, x):
# return self.conv(x) + self.shortcut(x)



Expand Down
Loading