Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
a6f197ae
Unverified
提交
a6f197ae
authored
7月 25, 2022
作者:
Glenn Jocher
提交者:
GitHub
7月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update dataloaders.py (#8714)
* Update dataloaders.py * Update dataloaders.py
上级
7215a0fb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
22 行删除
+14
-22
dataloaders.py
utils/dataloaders.py
+14
-22
没有找到文件。
utils/dataloaders.py
浏览文件 @
a6f197ae
...
...
@@ -3,6 +3,7 @@
Dataloaders and dataset utils
"""
import
contextlib
import
glob
import
hashlib
import
json
...
...
@@ -55,13 +56,10 @@ def get_hash(paths):
def
exif_size
(
img
):
# Returns exif-corrected PIL size
s
=
img
.
size
# (width, height)
try
:
with
contextlib
.
suppress
(
Exception
)
:
rotation
=
dict
(
img
.
_getexif
()
.
items
())[
orientation
]
if
rotation
in
[
6
,
8
]:
# rotation 270 or 90
s
=
(
s
[
1
],
s
[
0
])
except
Exception
:
pass
return
s
...
...
@@ -859,18 +857,13 @@ class LoadImagesAndLabels(Dataset):
# Ancillary functions --------------------------------------------------------------------------------------------------
def
create_folder
(
path
=
'./new'
):
# Create folder
if
os
.
path
.
exists
(
path
):
shutil
.
rmtree
(
path
)
# delete output folder
os
.
makedirs
(
path
)
# make new output folder
def
flatten_recursive
(
path
=
DATASETS_DIR
/
'coco128'
):
# Flatten a recursive directory by bringing all files to top level
new_path
=
Path
(
str
(
path
)
+
'_flat'
)
create_folder
(
new_path
)
for
file
in
tqdm
(
glob
.
glob
(
str
(
Path
(
path
))
+
'/**/*.*'
,
recursive
=
True
)):
new_path
=
Path
(
f
'{str(path)}_flat'
)
if
os
.
path
.
exists
(
new_path
):
shutil
.
rmtree
(
new_path
)
# delete output folder
os
.
makedirs
(
new_path
)
# make new output folder
for
file
in
tqdm
(
glob
.
glob
(
f
'{str(Path(path))}/**/*.*'
,
recursive
=
True
)):
shutil
.
copyfile
(
file
,
new_path
/
Path
(
file
)
.
name
)
...
...
@@ -929,7 +922,7 @@ def autosplit(path=DATASETS_DIR / 'coco128/images', weights=(0.9, 0.1, 0.0), ann
for
i
,
img
in
tqdm
(
zip
(
indices
,
files
),
total
=
n
):
if
not
annotated_only
or
Path
(
img2label_paths
([
str
(
img
)])[
0
])
.
exists
():
# check label
with
open
(
path
.
parent
/
txt
[
i
],
'a'
)
as
f
:
f
.
write
(
'./'
+
img
.
relative_to
(
path
.
parent
)
.
as_posix
()
+
'
\n
'
)
# add image to txt file
f
.
write
(
f
'./{img.relative_to(path.parent).as_posix()}'
+
'
\n
'
)
# add image to txt file
def
verify_image_label
(
args
):
...
...
@@ -1011,14 +1004,13 @@ def dataset_stats(path='coco128.yaml', autodownload=False, verbose=False, profil
def
_unzip
(
path
):
# Unzip data.zip
if
str
(
path
)
.
endswith
(
'.zip'
):
# path is data.zip
assert
Path
(
path
)
.
is_file
(),
f
'Error unzipping {path}, file not found'
ZipFile
(
path
)
.
extractall
(
path
=
path
.
parent
)
# unzip
dir
=
path
.
with_suffix
(
''
)
# dataset directory == zip name
assert
dir
.
is_dir
(),
f
'Error unzipping {path}, {dir} not found. path/to/abc.zip MUST unzip to path/to/abc/'
return
True
,
str
(
dir
),
_find_yaml
(
dir
)
# zipped, data_dir, yaml_path
else
:
# path is data.yaml
if
not
str
(
path
)
.
endswith
(
'.zip'
):
# path is data.yaml
return
False
,
None
,
path
assert
Path
(
path
)
.
is_file
(),
f
'Error unzipping {path}, file not found'
ZipFile
(
path
)
.
extractall
(
path
=
path
.
parent
)
# unzip
dir
=
path
.
with_suffix
(
''
)
# dataset directory == zip name
assert
dir
.
is_dir
(),
f
'Error unzipping {path}, {dir} not found. path/to/abc.zip MUST unzip to path/to/abc/'
return
True
,
str
(
dir
),
_find_yaml
(
dir
)
# zipped, data_dir, yaml_path
def
_hub_ops
(
f
,
max_dim
=
1920
):
# HUB ops for 1 image 'f': resize and save at reduced quality in /dataset-hub for web/app viewing
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论