Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
9c513ca6
Unverified
提交
9c513ca6
authored
2月 08, 2022
作者:
Glenn Jocher
提交者:
GitHub
2月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `DATASETS_DIR` global in general.py (#6578)
上级
f40854b6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
8 行删除
+9
-8
datasets.py
utils/datasets.py
+6
-6
general.py
utils/general.py
+3
-2
没有找到文件。
utils/datasets.py
浏览文件 @
9c513ca6
...
...
@@ -27,7 +27,7 @@ from torch.utils.data import DataLoader, Dataset, dataloader, distributed
from
tqdm
import
tqdm
from
utils.augmentations
import
Albumentations
,
augment_hsv
,
copy_paste
,
letterbox
,
mixup
,
random_perspective
from
utils.general
import
(
LOGGER
,
NUM_THREADS
,
check_dataset
,
check_requirements
,
check_yaml
,
clean_str
,
from
utils.general
import
(
DATASETS_DIR
,
LOGGER
,
NUM_THREADS
,
check_dataset
,
check_requirements
,
check_yaml
,
clean_str
,
segments2boxes
,
xyn2xy
,
xywh2xyxy
,
xywhn2xyxy
,
xyxy2xywhn
)
from
utils.torch_utils
import
torch_distributed_zero_first
...
...
@@ -817,15 +817,15 @@ def create_folder(path='./new'):
os
.
makedirs
(
path
)
# make new output folder
def
flatten_recursive
(
path
=
'../datasets/
coco128'
):
def
flatten_recursive
(
path
=
DATASETS_DIR
/
'
coco128'
):
# Flatten a recursive directory by bringing all files to top level
new_path
=
Path
(
path
+
'_flat'
)
new_path
=
Path
(
str
(
path
)
+
'_flat'
)
create_folder
(
new_path
)
for
file
in
tqdm
(
glob
.
glob
(
str
(
Path
(
path
))
+
'/**/*.*'
,
recursive
=
True
)):
shutil
.
copyfile
(
file
,
new_path
/
Path
(
file
)
.
name
)
def
extract_boxes
(
path
=
'../datasets/
coco128'
):
# from utils.datasets import *; extract_boxes()
def
extract_boxes
(
path
=
DATASETS_DIR
/
'
coco128'
):
# from utils.datasets import *; extract_boxes()
# Convert detection dataset into classification dataset, with one directory per class
path
=
Path
(
path
)
# images dir
shutil
.
rmtree
(
path
/
'classifier'
)
if
(
path
/
'classifier'
)
.
is_dir
()
else
None
# remove existing
...
...
@@ -859,7 +859,7 @@ def extract_boxes(path='../datasets/coco128'): # from utils.datasets import *;
assert
cv2
.
imwrite
(
str
(
f
),
im
[
b
[
1
]:
b
[
3
],
b
[
0
]:
b
[
2
]]),
f
'box failure in {f}'
def
autosplit
(
path
=
'../datasets/
coco128/images'
,
weights
=
(
0.9
,
0.1
,
0.0
),
annotated_only
=
False
):
def
autosplit
(
path
=
DATASETS_DIR
/
'
coco128/images'
,
weights
=
(
0.9
,
0.1
,
0.0
),
annotated_only
=
False
):
""" Autosplit a dataset into train/val/test splits and save path/autosplit_*.txt files
Usage: from utils.datasets import *; autosplit()
Arguments
...
...
@@ -939,7 +939,7 @@ def dataset_stats(path='coco128.yaml', autodownload=False, verbose=False, profil
""" Return dataset statistics dictionary with images and instances counts per split per class
To run in parent directory: export PYTHONPATH="$PWD/yolov5"
Usage1: from utils.datasets import *; dataset_stats('coco128.yaml', autodownload=True)
Usage2: from utils.datasets import *; dataset_stats('
../datasets
/coco128_with_yaml.zip')
Usage2: from utils.datasets import *; dataset_stats('
path/to
/coco128_with_yaml.zip')
Arguments
path: Path to data.yaml or data.zip (with data.yaml inside data.zip)
autodownload: Attempt to download dataset if not found locally
...
...
utils/general.py
浏览文件 @
9c513ca6
...
...
@@ -35,6 +35,7 @@ from utils.metrics import box_iou, fitness
# Settings
FILE
=
Path
(
__file__
)
.
resolve
()
ROOT
=
FILE
.
parents
[
1
]
# YOLOv5 root directory
DATASETS_DIR
=
ROOT
.
parent
/
'datasets'
# YOLOv5 datasets directory
NUM_THREADS
=
min
(
8
,
max
(
1
,
os
.
cpu_count
()
-
1
))
# number of YOLOv5 multiprocessing threads
VERBOSE
=
str
(
os
.
getenv
(
'YOLOv5_VERBOSE'
,
True
))
.
lower
()
==
'true'
# global verbose mode
FONT
=
'Arial.ttf'
# https://ultralytics.com/assets/Arial.ttf
...
...
@@ -398,8 +399,8 @@ def check_dataset(data, autodownload=True):
# Download (optional)
extract_dir
=
''
if
isinstance
(
data
,
(
str
,
Path
))
and
str
(
data
)
.
endswith
(
'.zip'
):
# i.e. gs://bucket/dir/coco128.zip
download
(
data
,
dir
=
'../datasets'
,
unzip
=
True
,
delete
=
False
,
curl
=
False
,
threads
=
1
)
data
=
next
((
Path
(
'../datasets'
)
/
Path
(
data
)
.
stem
)
.
rglob
(
'*.yaml'
))
download
(
data
,
dir
=
DATASETS_DIR
,
unzip
=
True
,
delete
=
False
,
curl
=
False
,
threads
=
1
)
data
=
next
((
DATASETS_DIR
/
Path
(
data
)
.
stem
)
.
rglob
(
'*.yaml'
))
extract_dir
,
autodownload
=
data
.
parent
,
False
# Read yaml (optional)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论