Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
467a57f0
Unverified
提交
467a57f0
authored
11月 18, 2022
作者:
Glenn Jocher
提交者:
GitHub
11月 18, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Segment prediction labels normalization fix (#10205)
* normalize_segments * round remove * swap axes fix
上级
ff6e6e32
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
11 行增加
和
8 行删除
+11
-8
predict.py
segment/predict.py
+1
-1
general.py
utils/general.py
+10
-7
没有找到文件。
segment/predict.py
浏览文件 @
467a57f0
...
@@ -156,7 +156,7 @@ def run(
...
@@ -156,7 +156,7 @@ def run(
# Segments
# Segments
if
save_txt
:
if
save_txt
:
segments
=
reversed
(
masks2segments
(
masks
))
segments
=
reversed
(
masks2segments
(
masks
))
segments
=
[
scale_segments
(
im
.
shape
[
2
:],
x
,
im0
.
shape
)
.
round
(
)
for
x
in
segments
]
segments
=
[
scale_segments
(
im
.
shape
[
2
:],
x
,
im0
.
shape
,
normalize
=
True
)
for
x
in
segments
]
# Print results
# Print results
for
c
in
det
[:,
5
]
.
unique
():
for
c
in
det
[:,
5
]
.
unique
():
...
...
utils/general.py
浏览文件 @
467a57f0
...
@@ -822,7 +822,7 @@ def scale_boxes(img1_shape, boxes, img0_shape, ratio_pad=None):
...
@@ -822,7 +822,7 @@ def scale_boxes(img1_shape, boxes, img0_shape, ratio_pad=None):
return
boxes
return
boxes
def
scale_segments
(
img1_shape
,
segments
,
img0_shape
,
ratio_pad
=
None
):
def
scale_segments
(
img1_shape
,
segments
,
img0_shape
,
ratio_pad
=
None
,
normalize
=
False
):
# Rescale coords (xyxy) from img1_shape to img0_shape
# Rescale coords (xyxy) from img1_shape to img0_shape
if
ratio_pad
is
None
:
# calculate from img0_shape
if
ratio_pad
is
None
:
# calculate from img0_shape
gain
=
min
(
img1_shape
[
0
]
/
img0_shape
[
0
],
img1_shape
[
1
]
/
img0_shape
[
1
])
# gain = old / new
gain
=
min
(
img1_shape
[
0
]
/
img0_shape
[
0
],
img1_shape
[
1
]
/
img0_shape
[
1
])
# gain = old / new
...
@@ -835,6 +835,9 @@ def scale_segments(img1_shape, segments, img0_shape, ratio_pad=None):
...
@@ -835,6 +835,9 @@ def scale_segments(img1_shape, segments, img0_shape, ratio_pad=None):
segments
[:,
1
]
-=
pad
[
1
]
# y padding
segments
[:,
1
]
-=
pad
[
1
]
# y padding
segments
/=
gain
segments
/=
gain
clip_segments
(
segments
,
img0_shape
)
clip_segments
(
segments
,
img0_shape
)
if
normalize
:
segments
[:,
0
]
/=
img0_shape
[
1
]
# width
segments
[:,
1
]
/=
img0_shape
[
0
]
# height
return
segments
return
segments
...
@@ -850,14 +853,14 @@ def clip_boxes(boxes, shape):
...
@@ -850,14 +853,14 @@ def clip_boxes(boxes, shape):
boxes
[:,
[
1
,
3
]]
=
boxes
[:,
[
1
,
3
]]
.
clip
(
0
,
shape
[
0
])
# y1, y2
boxes
[:,
[
1
,
3
]]
=
boxes
[:,
[
1
,
3
]]
.
clip
(
0
,
shape
[
0
])
# y1, y2
def
clip_segments
(
boxe
s
,
shape
):
def
clip_segments
(
segment
s
,
shape
):
# Clip segments (xy1,xy2,...) to image shape (height, width)
# Clip segments (xy1,xy2,...) to image shape (height, width)
if
isinstance
(
boxe
s
,
torch
.
Tensor
):
# faster individually
if
isinstance
(
segment
s
,
torch
.
Tensor
):
# faster individually
boxe
s
[:,
0
]
.
clamp_
(
0
,
shape
[
1
])
# x
segment
s
[:,
0
]
.
clamp_
(
0
,
shape
[
1
])
# x
boxe
s
[:,
1
]
.
clamp_
(
0
,
shape
[
0
])
# y
segment
s
[:,
1
]
.
clamp_
(
0
,
shape
[
0
])
# y
else
:
# np.array (faster grouped)
else
:
# np.array (faster grouped)
boxes
[:,
0
]
=
boxe
s
[:,
0
]
.
clip
(
0
,
shape
[
1
])
# x
segments
[:,
0
]
=
segment
s
[:,
0
]
.
clip
(
0
,
shape
[
1
])
# x
boxes
[:,
1
]
=
boxe
s
[:,
1
]
.
clip
(
0
,
shape
[
0
])
# y
segments
[:,
1
]
=
segment
s
[:,
1
]
.
clip
(
0
,
shape
[
0
])
# y
def
non_max_suppression
(
def
non_max_suppression
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论