forked from ultralytics/yolov5
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Randall
committed
Oct 28, 2022
1 parent
d3ea0df
commit 4390b71
Showing
6 changed files
with
220 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# YOLOv5 - rkopt 仓库 | ||
|
||
- 基于 https://github.com/ultralytics/yolov5 代码修改,设配 rknpu 设备的部署优化 | ||
- 切换分支 git checkout {分支名} | ||
- 目前支持分支: | ||
- master | ||
- maxpool/ focus 优化,输出改为个branch分支的输出。以上优化代码使用插入宏实现,不影响原来的训练逻辑,这个优化兼容修改前的权重,故支持官方给的预训练权重。 | ||
|
||
- 修改激活函数 silu 为 relu | ||
|
||
- 训练的相关内容请参考 README.md 说明 | ||
|
||
- 导出模型时 python export.py --rknpu {rk_platform} 即可导出优化模型 | ||
|
||
(rk_platform支持 rk1808, rv1109, rv1126, rk3399pro, rk3566, rk3568, rk3588, rv1103, rv1106) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file contains modules common to various models | ||
|
||
import torch | ||
import torch.nn as nn | ||
from models.common import Conv | ||
|
||
|
||
class surrogate_focus(nn.Module): | ||
# surrogate_focus wh information into c-space | ||
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, act=True): # ch_in, ch_out, kernel, stride, padding, groups | ||
super(surrogate_focus, self).__init__() | ||
self.conv = Conv(c1 * 4, c2, k, s, p, g, act) | ||
|
||
with torch.no_grad(): | ||
self.convsp = nn.Conv2d(3, 12, (2, 2), groups=1, bias=False, stride=(2, 2)) | ||
self.convsp.weight.data = torch.zeros(self.convsp.weight.shape).float() | ||
for i in range(4): | ||
for j in range(3): | ||
ch = i*3 + j | ||
if ch>=0 and ch<3: | ||
self.convsp.weight[ch:ch+1, j:j+1, 0, 0] = 1 | ||
elif ch>=3 and ch<6: | ||
self.convsp.weight[ch:ch+1, j:j+1, 1, 0] = 1 | ||
elif ch>=6 and ch<9: | ||
self.convsp.weight[ch:ch+1, j:j+1, 0, 1] = 1 | ||
elif ch>=9 and ch<12: | ||
self.convsp.weight[ch:ch+1, j:j+1, 1, 1] = 1 | ||
|
||
def forward(self, x): # x(b,c,w,h) -> y(b,4c,w/2,h/2) | ||
return self.conv(self.convsp(x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters