Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
4bdc5a39
Unverified
提交
4bdc5a39
authored
2月 05, 2021
作者:
Glenn Jocher
提交者:
GitHub
2月 05, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
LoadImages() pathlib update (#2140)
上级
73a06699
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
5 行增加
和
3 行删除
+5
-3
datasets.py
utils/datasets.py
+5
-3
没有找到文件。
utils/datasets.py
浏览文件 @
4bdc5a39
...
@@ -120,8 +120,7 @@ class _RepeatSampler(object):
...
@@ -120,8 +120,7 @@ class _RepeatSampler(object):
class
LoadImages
:
# for inference
class
LoadImages
:
# for inference
def
__init__
(
self
,
path
,
img_size
=
640
,
stride
=
32
):
def
__init__
(
self
,
path
,
img_size
=
640
,
stride
=
32
):
p
=
str
(
Path
(
path
))
# os-agnostic
p
=
str
(
Path
(
path
)
.
absolute
())
# os-agnostic absolute path
p
=
os
.
path
.
abspath
(
p
)
# absolute path
if
'*'
in
p
:
if
'*'
in
p
:
files
=
sorted
(
glob
.
glob
(
p
,
recursive
=
True
))
# glob
files
=
sorted
(
glob
.
glob
(
p
,
recursive
=
True
))
# glob
elif
os
.
path
.
isdir
(
p
):
elif
os
.
path
.
isdir
(
p
):
...
@@ -349,21 +348,24 @@ class LoadImagesAndLabels(Dataset): # for training/testing
...
@@ -349,21 +348,24 @@ 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
self
.
path
=
path
self
.
path
=
path
try
:
try
:
f
=
[]
# image files
f
=
[]
# image files
for
p
in
path
if
isinstance
(
path
,
list
)
else
[
path
]:
for
p
in
path
if
isinstance
(
path
,
list
)
else
[
path
]:
p
=
Path
(
p
)
# os-agnostic
p
=
Path
(
p
)
# os-agnostic
if
p
.
is_dir
():
# dir
if
p
.
is_dir
():
# dir
f
+=
glob
.
glob
(
str
(
p
/
'**'
/
'*.*'
),
recursive
=
True
)
f
+=
glob
.
glob
(
str
(
p
/
'**'
/
'*.*'
),
recursive
=
True
)
# f = list(p.rglob('**/*.*')) # pathlib
elif
p
.
is_file
():
# file
elif
p
.
is_file
():
# file
with
open
(
p
,
'r'
)
as
t
:
with
open
(
p
,
'r'
)
as
t
:
t
=
t
.
read
()
.
strip
()
.
splitlines
()
t
=
t
.
read
()
.
strip
()
.
splitlines
()
parent
=
str
(
p
.
parent
)
+
os
.
sep
parent
=
str
(
p
.
parent
)
+
os
.
sep
f
+=
[
x
.
replace
(
'./'
,
parent
)
if
x
.
startswith
(
'./'
)
else
x
for
x
in
t
]
# local to global path
f
+=
[
x
.
replace
(
'./'
,
parent
)
if
x
.
startswith
(
'./'
)
else
x
for
x
in
t
]
# local to global path
# f += [p.parent / x.lstrip(os.sep) for x in t] # local to global path (pathlib)
else
:
else
:
raise
Exception
(
f
'{prefix}{p} does not exist'
)
raise
Exception
(
f
'{prefix}{p} does not exist'
)
self
.
img_files
=
sorted
([
x
.
replace
(
'/'
,
os
.
sep
)
for
x
in
f
if
x
.
split
(
'.'
)[
-
1
]
.
lower
()
in
img_formats
])
self
.
img_files
=
sorted
([
x
.
replace
(
'/'
,
os
.
sep
)
for
x
in
f
if
x
.
split
(
'.'
)[
-
1
]
.
lower
()
in
img_formats
])
# self.img_files = sorted([x for x in f if x.suffix[1:].lower() in img_formats]) # pathlib
assert
self
.
img_files
,
f
'{prefix}No images found'
assert
self
.
img_files
,
f
'{prefix}No images found'
except
Exception
as
e
:
except
Exception
as
e
:
raise
Exception
(
f
'{prefix}Error loading data from {path}: {e}
\n
See {help_url}'
)
raise
Exception
(
f
'{prefix}Error loading data from {path}: {e}
\n
See {help_url}'
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论