Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
鹤冲天Pro
yolov7-obb
提交
cfca9ce1
Y
yolov7-obb
项目概览
鹤冲天Pro
/
yolov7-obb
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yolov7-obb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cfca9ce1
编写于
2月 02, 2023
作者:
_白鹭先生_
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复解耦
上级
be8c0376
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
45 deletion
+6
-45
utils/utils_bbox.py
utils/utils_bbox.py
+1
-45
yolo.py
yolo.py
+5
-0
未找到文件。
utils/utils_bbox.py
浏览文件 @
cfca9ce1
...
...
@@ -120,33 +120,6 @@ class DecodeBox():
outputs
.
append
(
output
.
data
)
return
outputs
def
yolo_correct_boxes
(
self
,
box_xy
,
box_wh
,
angle
,
input_shape
,
image_shape
,
letterbox_image
):
#-----------------------------------------------------------------#
# 把y轴放前面是因为方便预测框和图像的宽高进行相乘
#-----------------------------------------------------------------#
box_yx
=
box_xy
[...,
::
-
1
]
box_hw
=
box_wh
[...,
::
-
1
]
input_shape
=
np
.
array
(
input_shape
)
image_shape
=
np
.
array
(
image_shape
)
if
letterbox_image
:
#-----------------------------------------------------------------#
# 这里求出来的offset是图像有效区域相对于图像左上角的偏移情况
# new_shape指的是宽高缩放情况
#-----------------------------------------------------------------#
new_shape
=
np
.
round
(
image_shape
*
np
.
min
(
input_shape
/
image_shape
))
offset
=
(
input_shape
-
new_shape
)
/
2.
/
input_shape
scale
=
input_shape
/
new_shape
box_yx
=
(
box_yx
-
offset
)
*
scale
box_hw
*=
scale
box_xy
=
box_yx
[...,
::
-
1
]
*
image_shape
box_wh
=
box_hw
[...,
::
-
1
]
*
image_shape
boxes
=
np
.
concatenate
([
box_xy
[...,
0
:
1
],
box_xy
[...,
1
:
2
],
box_wh
[...,
0
:
1
],
box_wh
[...,
1
:
2
],
angle
[...,
0
:
1
]
],
axis
=-
1
)
return
boxes
def
non_max_suppression
(
self
,
prediction
,
num_classes
,
input_shape
,
image_shape
,
letterbox_image
,
conf_thres
=
0.5
,
nms_thres
=
0.4
):
#----------------------------------------------------------#
# prediction [batch_size, num_anchors, 85]
...
...
@@ -205,28 +178,11 @@ class DecodeBox():
)
max_detections
=
detections_class
[
keep
]
# # 按照存在物体的置信度排序
# _, conf_sort_index = torch.sort(detections_class[:, 4]*detections_class[:, 5], descending=True)
# detections_class = detections_class[conf_sort_index]
# # 进行非极大抑制
# max_detections = []
# while detections_class.size(0):
# # 取出这一类置信度最高的,一步一步往下判断,判断重合程度是否大于nms_thres,如果是则去除掉
# max_detections.append(detections_class[0].unsqueeze(0))
# if len(detections_class) == 1:
# break
# ious = bbox_iou(max_detections[-1], detections_class[1:])
# detections_class = detections_class[1:][ious < nms_thres]
# # 堆叠
# max_detections = torch.cat(max_detections).data
# Add max detections to outputs
output
[
i
]
=
max_detections
if
output
[
i
]
is
None
else
torch
.
cat
((
output
[
i
],
max_detections
))
if
output
[
i
]
is
not
None
:
output
[
i
]
=
output
[
i
].
cpu
().
numpy
()
box_xy
,
box_wh
,
angle
=
output
[
i
][:,
0
:
2
],
output
[
i
][:,
2
:
4
],
output
[
i
][:,
4
:
5
]
output
[
i
][:,
:
5
]
=
self
.
yolo_correct_boxes
(
box_xy
,
box_wh
,
angle
,
input_shape
,
image_shape
,
letterbox_image
)
output
[
i
]
=
output
[
i
].
cpu
().
numpy
()
return
output
if
__name__
==
"__main__"
:
...
...
yolo.py
浏览文件 @
cfca9ce1
...
...
@@ -158,6 +158,11 @@ class YOLO(object):
top_conf
=
results
[
0
][:,
5
]
*
results
[
0
][:,
6
]
top_rboxes
=
results
[
0
][:,
:
5
]
top_polys
=
rbox2poly
(
top_rboxes
)
#---------------------------------------------------------#
# 将归一化的预测结果变为真实的预测框
#---------------------------------------------------------#
top_polys
[...,
[
0
,
2
,
4
,
6
]]
*=
image_shape
[
0
]
top_polys
[...,
[
1
,
3
,
5
,
7
]]
*=
image_shape
[
1
]
#---------------------------------------------------------#
# 设置字体与边框厚度
#---------------------------------------------------------#
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录