Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
9532fbdc
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9532fbdc
编写于
5月 26, 2021
作者:
K
Kaipeng Deng
提交者:
GitHub
5月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update version and config download (#3153)
* update version and config download
上级
3a312657
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
84 addition
and
37 deletion
+84
-37
.gitignore
.gitignore
+2
-0
ppdet/__init__.py
ppdet/__init__.py
+10
-0
ppdet/utils/download.py
ppdet/utils/download.py
+32
-36
setup.py
setup.py
+40
-1
未找到文件。
.gitignore
浏览文件 @
9532fbdc
...
...
@@ -78,3 +78,5 @@ dataset/wider_face/WIDER_test
dataset/wider_face/WIDER_train
dataset/wider_face/WIDER_val
dataset/wider_face/wider_face_split
ppdet/version.py
ppdet/__init__.py
浏览文件 @
9532fbdc
...
...
@@ -14,3 +14,13 @@
from
.
import
(
core
,
data
,
engine
,
modeling
,
model_zoo
,
optimizer
,
metrics
,
utils
,
slim
)
try
:
from
.version
import
full_version
as
__version__
from
.version
import
commit
as
__git_commit__
except
ImportError
:
import
sys
sys
.
stderr
.
write
(
"Warning: import ppdet from source directory "
\
"without installing, run 'python setup.py install' to "
\
"install ppdet firstly
\n
"
)
ppdet/utils/download.py
浏览文件 @
9532fbdc
...
...
@@ -118,44 +118,36 @@ def get_config_path(url):
download it from url.
"""
url
=
parse_url
(
url
)
path
,
_
=
get_path
(
url
,
CONFIGS_HOME
)
_download_config
(
path
,
url
,
CONFIGS_HOME
)
return
path
def
_download_config
(
cfg_path
,
cfg_url
,
cur_dir
):
with
open
(
cfg_path
)
as
f
:
cfg
=
yaml
.
load
(
f
,
Loader
=
yaml
.
Loader
)
path
=
map_path
(
url
,
CONFIGS_HOME
,
path_depth
=
2
)
if
os
.
path
.
isfile
(
path
):
return
path
# download dependence base ymls
if
BASE_KEY
in
cfg
:
base_ymls
=
list
(
cfg
[
BASE_KEY
])
for
base_yml
in
base_ymls
:
if
base_yml
.
startswith
(
"~"
):
base_yml
=
os
.
path
.
expanduser
(
base_yml
)
relpath
=
osp
.
relpath
(
base_yml
,
cfg_path
)
if
not
base_yml
.
startswith
(
'/'
):
relpath
=
base_yml
base_yml
=
os
.
path
.
join
(
os
.
path
.
dirname
(
cfg_path
),
base_yml
)
# config file not found, try download
# 1. clear configs directory
if
osp
.
isdir
(
CONFIGS_HOME
):
shutil
.
rmtree
(
CONFIGS_HOME
)
if
osp
.
isfile
(
base_yml
):
logger
.
debug
(
"Found _BASE_ config: {}"
.
format
(
base_yml
))
continue
# 2. get url
try
:
from
ppdet
import
__version__
as
version
except
ImportError
:
version
=
None
# download to CONFIGS_HOME firstly
base_yml_url
=
osp
.
join
(
osp
.
split
(
cfg_url
)[
0
],
relpath
)
path
,
_
=
get_path
(
base_yml_url
,
CONFIGS_HOME
)
cfg_url
=
"ppdet://configs/{}/configs.tar"
.
format
(
version
)
\
if
version
else
"ppdet://configs/configs.tar"
cfg_url
=
parse_url
(
cfg_url
)
# move from CONFIGS_HOME to dst_path to restore config directory structure
dst_path
=
osp
.
join
(
cur_dir
,
relpath
)
dst_dir
=
osp
.
split
(
dst_path
)[
0
]
if
not
osp
.
isdir
(
dst_dir
):
os
.
makedirs
(
dst_dir
)
shutil
.
move
(
path
,
dst_path
)
# 3. download and decompress
cfg_fullname
=
_download
(
cfg_url
,
osp
.
dirname
(
CONFIGS_HOME
))
_decompress
(
cfg_fullname
)
# perfrom download base yml recursively
_download_config
(
dst_path
,
base_yml_url
,
osp
.
split
(
dst_path
)[
0
])
# 4. check config file existing
if
os
.
path
.
isfile
(
path
):
return
path
else
:
logger
.
error
(
"Get config {} failed after download, please contact us on "
\
"https://github.com/PaddlePaddle/PaddleDetection/issues"
.
format
(
path
))
sys
.
exit
(
1
)
def
get_dataset_path
(
path
,
annotation
,
image_dir
):
...
...
@@ -235,11 +227,15 @@ def create_voc_list(data_dir, devkit_subdir='VOCdevkit'):
logger
.
debug
(
"Create voc file list finished"
)
def
map_path
(
url
,
root_dir
):
def
map_path
(
url
,
root_dir
,
path_depth
=
1
):
# parse path after download to decompress under root_dir
fname
=
osp
.
split
(
url
)[
-
1
]
assert
path_depth
>
0
,
"path_depth should be a positive integer"
dirname
=
url
for
_
in
range
(
path_depth
):
dirname
=
osp
.
dirname
(
dirname
)
fpath
=
osp
.
relpath
(
url
,
dirname
)
zip_formats
=
[
'.zip'
,
'.tar'
,
'.gz'
]
fpath
=
fname
for
zip_format
in
zip_formats
:
fpath
=
fpath
.
replace
(
zip_format
,
''
)
return
osp
.
join
(
root_dir
,
fpath
)
...
...
setup.py
浏览文件 @
9532fbdc
...
...
@@ -16,9 +16,48 @@ import os
import
os.path
as
osp
import
glob
import
shutil
import
subprocess
from
setuptools
import
find_packages
,
setup
# ============== version definition ==============
PPDET_VERSION
=
"2.1.0"
def
parse_version
():
return
PPDET_VERSION
.
replace
(
'-'
,
''
)
def
git_commit
():
try
:
cmd
=
[
'git'
,
'rev-parse'
,
'HEAD'
]
git_commit
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
).
communicate
()[
0
].
strip
()
git_commit
=
git_commit
.
decode
()
except
:
git_commit
=
'Unknown'
return
str
(
git_commit
)
def
write_version_py
(
filename
=
'ppdet/version.py'
):
ver_str
=
"""# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY
#
full_version = '%(version)s'
commit = '%(commit)s'
"""
_git_commit
=
git_commit
()
with
open
(
filename
,
'w'
)
as
f
:
f
.
write
(
ver_str
%
{
'version'
:
PPDET_VERSION
,
'commit'
:
_git_commit
})
write_version_py
()
# ============== version definition ==============
def
readme
():
with
open
(
'README.md'
,
encoding
=
'utf-8'
)
as
f
:
content
=
f
.
read
()
...
...
@@ -71,7 +110,7 @@ if __name__ == "__main__":
packages
=
find_packages
(
exclude
=
(
"configs"
,
"tools"
,
"deploy"
)),
package_data
=
{
'ppdet.model_zoo'
:
package_model_zoo
()},
author
=
'PaddlePaddle'
,
version
=
'2.1.0'
,
version
=
parse_version
()
,
install_requires
=
parse_requirements
(
'./requirements.txt'
),
description
=
'Object detection and instance segmentation toolkit based on PaddlePaddle'
,
long_description
=
readme
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录