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

changes are done as per the documentation of kneron. #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added __pycache__/test.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion cfg/yolov7-tiny-face.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nc: 1 # number of classes
nkpt: 5 # number of keypoints
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # layer channel multiple
width_multiple: 0.5 # layer channel multiple
dw_conv_kpt: True

anchors:
Expand Down
2 changes: 1 addition & 1 deletion cfg/yolov7s-face.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nc: 1 # number of classes
nkpt: 5 # number of keypoints
depth_multiple: 1.0 # model depth multiple
width_multiple: 0.4 # layer channel multiple
width_multiple: 0.5 # layer channel multiple
dw_conv_kpt: False

anchors:
Expand Down
4 changes: 2 additions & 2 deletions data/widerface.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


# train and val data as 1) directory: path/images/, 2) file: path/images.txt, or 3) list: [path1/images/, path2/images/]
train: data/widerface/train # 16551 images
val: data/widerface/val # 16551 images
train: C:\Mantra_works\Facial\Dataset\Save\Wider_face_train # 16551 images
val: C:\Mantra_works\Facial\Dataset\Save\Wider_face_vald # 16551 images
#val: /ssd_1t/derron/yolov5-face/data/widerface/train/ # 4952 images

# number of classes
Expand Down
Binary file added models/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/common.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/experimental.cpython-310.pyc
Binary file not shown.
Binary file added models/__pycache__/yolo.cpython-310.pyc
Binary file not shown.
22 changes: 11 additions & 11 deletions models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, k
self.conv = nn.Conv2d(c1, c2, k, s, autopad(k, p), groups=g, bias=False)
self.bn = nn.BatchNorm2d(c2)
if act != "ReLU":
self.act = nn.SiLU() if act is True else (act if isinstance(act, nn.Module) else nn.Identity())
self.act = nn.LeakyReLU(0.1, inplace=True) if act is True else (act if isinstance(act, nn.Module) else nn.Identity())
else:
self.act = nn.ReLU(inplace=True)

Expand Down Expand Up @@ -173,7 +173,7 @@ def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, nu
self.cv3 = nn.Conv2d(c_, c_, 1, 1, bias=False)
self.cv4 = Conv(2 * c_, c2, 1, 1)
self.bn = nn.BatchNorm2d(2 * c_) # applied to cat(cv2, cv3)
self.act = nn.SiLU()
self.act = nn.LeakyReLU(0.1, inplace=True)
self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])

def forward(self, x):
Expand All @@ -192,7 +192,7 @@ def __init__(self, c1, c2, n=1, shortcut=True, g=1, e=0.5): # ch_in, ch_out, nu
#self.cv3 = nn.Conv2d(c_, c_, 1, 1, bias=False)
self.cv4 = Conv(2 * c_, c2, 1, 1)
self.bn = nn.BatchNorm2d(2 * c_) # applied to cat(cv2, cv3)
self.act = nn.SiLU()
self.act = nn.LeakyReLU(0.1, inplace=True)
self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])

def forward(self, x):
Expand All @@ -210,7 +210,7 @@ def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5): # ch_in, ch_out, n
self.cv2 = nn.Conv2d(c_, c_, 1, 1, bias=False)
self.cv3 = Conv(2 * c_, c2, 1, 1)
self.bn = nn.BatchNorm2d(2 * c_)
self.act = nn.SiLU()
self.act = nn.LeakyReLU(0.1, inplace=True)
self.m = nn.Sequential(*[Bottleneck(c_, c_, shortcut, g, e=1.0) for _ in range(n)])

def forward(self, x):
Expand Down Expand Up @@ -281,7 +281,7 @@ def __init__(self, c1, c2, n=1, shortcut=False, g=1, e=0.5, k=(5, 9, 13)):
self.cv5 = Conv(4 * c_, c_, 1, 1)
self.cv6 = Conv(c_, c_, 3, 1)
self.bn = nn.BatchNorm2d(2 * c_)
self.act = nn.SiLU()
self.act = nn.LeakyReLU(0.1, inplace=True)
self.cv7 = Conv(2 * c_, c2, 1, 1)

def forward(self, x):
Expand Down Expand Up @@ -442,7 +442,7 @@ def __init__(self, c1, c2): # ch_in, ch_out
self.conv = nn.Sequential(
nn.Conv2d(c1, c2, kernel_size=3, stride=2, padding=1, bias=False),
nn.BatchNorm2d(c2),
nn.SiLU(inplace=True),
nn.LeakyReLU(0.1, inplace=True),
)
self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)

Expand All @@ -456,10 +456,10 @@ def __init__(self, in_channels, out_channels, k, s):
self.p = k // 2
self.conv1 = nn.Conv2d(in_channels, in_channels, kernel_size=k, stride=s, padding=self.p, groups=in_channels, bias=False)
self.bn1 = nn.BatchNorm2d(in_channels)
self.act1 = nn.SiLU(inplace=True)
self.act1 = nn.LeakyReLU(0.1, inplace=True)
self.conv2 = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=1, padding=0, bias=False)
self.bn2 = nn.BatchNorm2d(out_channels)
self.act2 = nn.SiLU(inplace=True)
self.act2 = nn.LeakyReLU(0.1, inplace=True)

def forward(self, x):
x = self.conv1(x)
Expand Down Expand Up @@ -508,19 +508,19 @@ def __init__(self, inp, oup, stride):
nn.BatchNorm2d(inp),
nn.Conv2d(inp, branch_features, kernel_size=1, stride=1, padding=0, bias=False),
nn.BatchNorm2d(branch_features),
nn.SiLU(inplace=True),
nn.LeakyReLU(0.1, inplace=True),
)

self.branch2 = nn.Sequential(
nn.Conv2d(inp if (self.stride > 1) else branch_features,
branch_features, kernel_size=1, stride=1, padding=0, bias=False),
nn.BatchNorm2d(branch_features),
nn.SiLU(inplace=True),
nn.LeakyReLU(0.1, inplace=True),
self.depthwise_conv(branch_features, branch_features, kernel_size=3, stride=self.stride, padding=1),
nn.BatchNorm2d(branch_features),
nn.Conv2d(branch_features, branch_features, kernel_size=1, stride=1, padding=0, bias=False),
nn.BatchNorm2d(branch_features),
nn.SiLU(inplace=True),
nn.LeakyReLU(0.1, inplace=True),
)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def test(data,
cv2.imwrite( dst_file, img[0].numpy().transpose(1,2,0)[:,:,::-1])
#print(img.shape)
img = img.half() if half else img.float() # uint8 to fp16/32
img /= 255.0 # 0 - 255 to 0.0 - 1.0
img /= 256.0-0.5 # 0 - 255 to 0.0 - 1.0
targets = targets.to(device)
nb, _, height, width = img.shape # batch size, channels, height, width
with torch.no_grad():
Expand Down
2 changes: 1 addition & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def train(hyp, opt, device, tb_writer=None):
# if i>10:
# break
ni = i + nb * epoch # number integrated batches (since train start)
imgs = imgs.to(device, non_blocking=True).float() / 255.0 # uint8 to float32, 0-255 to 0.0-1.0
imgs = imgs.to(device, non_blocking=True).float() / 256.0-0.5 # uint8 to float32, 0-255 to 0.0-1.0

# Warmup
if ni <= nw:
Expand Down
Binary file added utils/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/autoanchor.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/datasets.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/general.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/google_utils.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/loss.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/metrics.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/plots.cpython-310.pyc
Binary file not shown.
Binary file added utils/__pycache__/torch_utils.cpython-310.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added yolov7-tiny.pt
Binary file not shown.