Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
b9da3ea4
提交
b9da3ea4
authored
6月 30, 2020
作者:
Glenn Jocher
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
3b16c865
bfd51f62
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
1 行删除
+21
-1
datasets.py
utils/datasets.py
+21
-1
没有找到文件。
utils/datasets.py
浏览文件 @
b9da3ea4
...
@@ -310,7 +310,6 @@ class LoadImagesAndLabels(Dataset): # for training/testing
...
@@ -310,7 +310,6 @@ class LoadImagesAndLabels(Dataset): # for training/testing
self
.
mosaic_border
=
[
-
img_size
//
2
,
-
img_size
//
2
]
self
.
mosaic_border
=
[
-
img_size
//
2
,
-
img_size
//
2
]
self
.
stride
=
stride
self
.
stride
=
stride
# Define labels
# Define labels
self
.
label_files
=
[
x
.
replace
(
'images'
,
'labels'
)
.
replace
(
os
.
path
.
splitext
(
x
)[
-
1
],
'.txt'
)
self
.
label_files
=
[
x
.
replace
(
'images'
,
'labels'
)
.
replace
(
os
.
path
.
splitext
(
x
)[
-
1
],
'.txt'
)
for
x
in
self
.
img_files
]
for
x
in
self
.
img_files
]
...
@@ -629,6 +628,9 @@ def load_mosaic(self, index):
...
@@ -629,6 +628,9 @@ def load_mosaic(self, index):
# np.clip(labels4[:, 1:] - s / 2, 0, s, out=labels4[:, 1:]) # use with center crop
# np.clip(labels4[:, 1:] - s / 2, 0, s, out=labels4[:, 1:]) # use with center crop
np
.
clip
(
labels4
[:,
1
:],
0
,
2
*
s
,
out
=
labels4
[:,
1
:])
# use with random_affine
np
.
clip
(
labels4
[:,
1
:],
0
,
2
*
s
,
out
=
labels4
[:,
1
:])
# use with random_affine
# Replicate
# img4, labels4 = replicate(img4, labels4)
# Augment
# Augment
# img4 = img4[s // 2: int(s * 1.5), s // 2:int(s * 1.5)] # center crop (WARNING, requires box pruning)
# img4 = img4[s // 2: int(s * 1.5), s // 2:int(s * 1.5)] # center crop (WARNING, requires box pruning)
img4
,
labels4
=
random_affine
(
img4
,
labels4
,
img4
,
labels4
=
random_affine
(
img4
,
labels4
,
...
@@ -641,6 +643,23 @@ def load_mosaic(self, index):
...
@@ -641,6 +643,23 @@ def load_mosaic(self, index):
return
img4
,
labels4
return
img4
,
labels4
def
replicate
(
img
,
labels
):
# Replicate labels
h
,
w
=
img
.
shape
[:
2
]
boxes
=
labels
[:,
1
:]
.
astype
(
int
)
x1
,
y1
,
x2
,
y2
=
boxes
.
T
s
=
((
x2
-
x1
)
+
(
y2
-
y1
))
/
2
# side length (pixels)
for
i
in
s
.
argsort
()[:
round
(
s
.
size
*
0.5
)]:
# smallest indices
x1b
,
y1b
,
x2b
,
y2b
=
boxes
[
i
]
bh
,
bw
=
y2b
-
y1b
,
x2b
-
x1b
yc
,
xc
=
int
(
random
.
uniform
(
0
,
h
-
bh
)),
int
(
random
.
uniform
(
0
,
w
-
bw
))
# offset x, y
x1a
,
y1a
,
x2a
,
y2a
=
[
xc
,
yc
,
xc
+
bw
,
yc
+
bh
]
img
[
y1a
:
y2a
,
x1a
:
x2a
]
=
img
[
y1b
:
y2b
,
x1b
:
x2b
]
# img4[ymin:ymax, xmin:xmax]
labels
=
np
.
append
(
labels
,
[[
labels
[
i
,
0
],
x1a
,
y1a
,
x2a
,
y2a
]],
axis
=
0
)
return
img
,
labels
def
letterbox
(
img
,
new_shape
=
(
640
,
640
),
color
=
(
114
,
114
,
114
),
auto
=
True
,
scaleFill
=
False
,
scaleup
=
True
):
def
letterbox
(
img
,
new_shape
=
(
640
,
640
),
color
=
(
114
,
114
,
114
),
auto
=
True
,
scaleFill
=
False
,
scaleup
=
True
):
# Resize image to a 32-pixel-multiple rectangle https://github.com/ultralytics/yolov3/issues/232
# Resize image to a 32-pixel-multiple rectangle https://github.com/ultralytics/yolov3/issues/232
shape
=
img
.
shape
[:
2
]
# current shape [height, width]
shape
=
img
.
shape
[:
2
]
# current shape [height, width]
...
@@ -765,6 +784,7 @@ def cutout(image, labels):
...
@@ -765,6 +784,7 @@ def cutout(image, labels):
box2_area
=
(
b2_x2
-
b2_x1
)
*
(
b2_y2
-
b2_y1
)
+
1e-16
box2_area
=
(
b2_x2
-
b2_x1
)
*
(
b2_y2
-
b2_y1
)
+
1e-16
# Intersection over box2 area
# Intersection over box2 area
return
inter_area
/
box2_area
return
inter_area
/
box2_area
# create random masks
# create random masks
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论