Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
7715f42e
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
281
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7715f42e
编写于
12月 25, 2019
作者:
K
kinghuin
提交者:
wuzewu
12月 25, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove needless import (#258)
* remove needless import Co-authored-by:
N
wuzewu
<
wuzewu@baidu.com
>
上级
ca3e9774
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
43 addition
and
60 deletion
+43
-60
paddlehub/__init__.py
paddlehub/__init__.py
+2
-3
paddlehub/commands/autofinetune.py
paddlehub/commands/autofinetune.py
+0
-13
paddlehub/commands/download.py
paddlehub/commands/download.py
+5
-5
paddlehub/commands/hub.py
paddlehub/commands/hub.py
+2
-6
paddlehub/commands/install.py
paddlehub/commands/install.py
+3
-0
paddlehub/commands/run.py
paddlehub/commands/run.py
+0
-4
paddlehub/commands/search.py
paddlehub/commands/search.py
+3
-3
paddlehub/common/hub_server.py
paddlehub/common/hub_server.py
+25
-7
paddlehub/common/paddle_helper.py
paddlehub/common/paddle_helper.py
+0
-1
paddlehub/common/srv_utils.py
paddlehub/common/srv_utils.py
+0
-5
paddlehub/common/utils.py
paddlehub/common/utils.py
+0
-2
paddlehub/finetune/regularizer.py
paddlehub/finetune/regularizer.py
+0
-1
paddlehub/finetune/strategy.py
paddlehub/finetune/strategy.py
+0
-2
paddlehub/module/manager.py
paddlehub/module/manager.py
+3
-7
paddlehub/module/module.py
paddlehub/module/module.py
+0
-1
未找到文件。
paddlehub/__init__.py
浏览文件 @
7715f42e
...
...
@@ -36,7 +36,8 @@ from .common.dir import CACHE_HOME
from
.common.dir
import
CONF_HOME
from
.common.logger
import
logger
from
.common.paddle_helper
import
connect_program
from
.common.hub_server
import
default_hub_server
from
.common.hub_server
import
HubServer
from
.common.hub_server
import
server_check
from
.module.module
import
Module
from
.module.base_processor
import
BaseProcessor
...
...
@@ -61,5 +62,3 @@ from .finetune.strategy import ULMFiTStrategy
from
.finetune.strategy
import
CombinedStrategy
from
.autofinetune.evaluator
import
report_final_result
from
.common.hub_server
import
server_check
paddlehub/commands/autofinetune.py
浏览文件 @
7715f42e
...
...
@@ -18,26 +18,13 @@ from __future__ import division
from
__future__
import
print_function
import
argparse
import
io
import
json
import
os
import
sys
import
ast
import
six
import
shutil
import
pandas
import
numpy
as
np
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
from
paddlehub.common.arg_helper
import
add_argument
,
print_arguments
from
paddlehub.autofinetune.autoft
import
PSHE2
from
paddlehub.autofinetune.autoft
import
HAZero
from
paddlehub.autofinetune.evaluator
import
FullTrailEvaluator
from
paddlehub.autofinetune.evaluator
import
PopulationBasedEvaluator
from
paddlehub.common.logger
import
logger
import
paddlehub
as
hub
class
AutoFineTuneCommand
(
BaseCommand
):
...
...
paddlehub/commands/download.py
浏览文件 @
7715f42e
...
...
@@ -20,9 +20,9 @@ from __future__ import print_function
import
argparse
import
os
import
paddlehub
as
hub
from
paddlehub.common
import
utils
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.common.hub_server
import
default_hub_server
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
...
...
@@ -57,20 +57,20 @@ class DownloadCommand(BaseCommand):
extra
=
{
"command"
:
"download"
}
if
self
.
args
.
type
in
[
"Module"
,
"Model"
]:
search_result
=
default_hub_server
.
get_resource_url
(
search_result
=
hub
.
HubServer
()
.
get_resource_url
(
mod_name
,
resource_type
=
self
.
args
.
type
,
version
=
mod_version
,
extra
=
extra
)
else
:
search_result
=
default_hub_server
.
get_resource_url
(
search_result
=
hub
.
HubServer
()
.
get_resource_url
(
mod_name
,
resource_type
=
"Module"
,
version
=
mod_version
,
extra
=
extra
)
self
.
args
.
type
=
"Module"
if
search_result
==
{}:
search_result
=
default_hub_server
.
get_resource_url
(
search_result
=
hub
.
HubServer
()
.
get_resource_url
(
mod_name
,
resource_type
=
"Model"
,
version
=
mod_version
,
...
...
@@ -79,7 +79,7 @@ class DownloadCommand(BaseCommand):
url
=
search_result
.
get
(
'url'
,
None
)
except_md5_value
=
search_result
.
get
(
'md5'
,
None
)
if
not
url
:
if
default_hub_server
.
_server_check
()
is
False
:
if
hub
.
HubServer
()
.
_server_check
()
is
False
:
tips
=
"Request Hub-Server unsuccessfully, please check your network."
else
:
tips
=
"PaddleHub can't find model/module named %s"
%
mod_name
...
...
paddlehub/commands/hub.py
浏览文件 @
7715f42e
...
...
@@ -20,15 +20,11 @@ from __future__ import print_function
import
six
import
sys
from
paddlehub.commands.base_command
import
BaseCommand
from
paddlehub.common.logger
import
logger
from
paddlehub.common.utils
import
sys_stdin_encoding
from
paddlehub.common
import
srv_utils
from
paddlehub.commands.base_command
import
BaseCommand
from
paddlehub.commands
import
show
from
paddlehub.commands
import
help
from
paddlehub.commands
import
version
from
paddlehub.commands
import
run
from
paddlehub.commands
import
download
class
HubCommand
(
BaseCommand
):
...
...
paddlehub/commands/install.py
浏览文件 @
7715f42e
...
...
@@ -44,6 +44,7 @@ class InstallCommand(BaseCommand):
self
.
help
()
return
False
extra
=
{
"command"
:
"install"
}
if
argv
[
0
].
endswith
(
"tar.gz"
)
or
argv
[
0
].
endswith
(
"phm"
):
result
,
tips
,
module_dir
=
default_module_manager
.
install_module
(
module_package
=
argv
[
0
],
extra
=
extra
)
...
...
@@ -60,7 +61,9 @@ class InstallCommand(BaseCommand):
module_name
=
module_name
,
module_version
=
module_version
,
extra
=
extra
)
print
(
tips
)
return
True
...
...
paddlehub/commands/run.py
浏览文件 @
7715f42e
...
...
@@ -20,20 +20,16 @@ from __future__ import print_function
import
argparse
import
json
import
os
import
sys
import
ast
import
six
import
pandas
import
imghdr
import
cv2
import
numpy
as
np
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
from
paddlehub.io.parser
import
yaml_parser
,
txt_parser
from
paddlehub.module.manager
import
default_module_manager
from
paddlehub.common
import
utils
from
paddlehub.common.arg_helper
import
add_argument
,
print_arguments
import
paddlehub
as
hub
...
...
paddlehub/commands/search.py
浏览文件 @
7715f42e
...
...
@@ -19,8 +19,8 @@ from __future__ import print_function
import
argparse
import
paddlehub
as
hub
from
paddlehub.common
import
utils
from
paddlehub.common.hub_server
import
default_hub_server
from
paddlehub.commands.base_command
import
BaseCommand
,
ENTRY
from
paddlehub.common.cml_utils
import
TablePrinter
...
...
@@ -44,7 +44,7 @@ class SearchCommand(BaseCommand):
resource_name
=
argv
[
0
]
extra
=
{
"command"
:
"search"
}
resource_list
=
default_hub_server
.
search_resource
(
resource_list
=
hub
.
HubServer
()
.
search_resource
(
resource_name
,
resource_type
=
"Module"
,
extra
=
extra
)
if
utils
.
is_windows
():
placeholders
=
[
20
,
8
,
8
,
20
]
...
...
@@ -54,7 +54,7 @@ class SearchCommand(BaseCommand):
titles
=
[
"ResourceName"
,
"Type"
,
"Version"
,
"Summary"
],
placeholders
=
placeholders
)
if
len
(
resource_list
)
==
0
:
if
default_hub_server
.
_server_check
()
is
False
:
if
hub
.
HubServer
()
.
_server_check
()
is
False
:
print
(
"Request Hub-Server unsuccessfully, please check your network."
)
...
...
paddlehub/common/hub_server.py
浏览文件 @
7715f42e
...
...
@@ -26,7 +26,6 @@ import yaml
import
random
import
threading
from
random
import
randint
from
paddlehub.common
import
utils
,
srv_utils
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.common.server_config
import
default_server_config
...
...
@@ -38,6 +37,29 @@ RESOURCE_LIST_FILE = "resource_list_file.yml"
CACHE_TIME
=
60
*
10
def
synchronized
(
func
):
func
.
__lock__
=
threading
.
Lock
()
def
synced_func
(
*
args
,
**
kwargs
):
with
func
.
__lock__
:
return
func
(
*
args
,
**
kwargs
)
return
synced_func
def
singleton
(
cls
):
_instance
=
{}
@
synchronized
def
_get_instance
(
*
args
,
**
kwargs
):
if
cls
not
in
_instance
:
_instance
[
cls
]
=
cls
(
*
args
,
**
kwargs
)
return
_instance
[
cls
]
return
_get_instance
@
singleton
class
HubServer
(
object
):
def
__init__
(
self
,
config_file_path
=
None
):
if
not
config_file_path
:
...
...
@@ -295,8 +317,7 @@ class CacheUpdater(threading.Thread):
payload
=
{
'word'
:
module
}
if
version
:
payload
[
'version'
]
=
version
api_url
=
srv_utils
.
uri_path
(
default_hub_server
.
get_server_url
(),
'search'
)
api_url
=
srv_utils
.
uri_path
(
HubServer
().
get_server_url
(),
'search'
)
cache_path
=
os
.
path
.
join
(
CACHE_HOME
,
RESOURCE_LIST_FILE
)
if
os
.
path
.
exists
(
cache_path
):
extra
=
{
...
...
@@ -321,7 +342,4 @@ class CacheUpdater(threading.Thread):
def
server_check
():
default_hub_server
.
server_check
()
default_hub_server
=
HubServer
()
HubServer
().
server_check
()
paddlehub/common/paddle_helper.py
浏览文件 @
7715f42e
...
...
@@ -19,7 +19,6 @@ from __future__ import print_function
import
copy
import
paddle
import
paddle.fluid
as
fluid
from
paddlehub.module
import
module_desc_pb2
...
...
paddlehub/common/srv_utils.py
浏览文件 @
7715f42e
...
...
@@ -12,15 +12,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
os
import
requests
import
time
import
paddle
import
socket
import
json
from
random
import
randint
,
seed
from
paddlehub
import
version
...
...
paddlehub/common/utils.py
浏览文件 @
7715f42e
...
...
@@ -19,12 +19,10 @@ from __future__ import print_function
import
sys
import
os
import
time
import
multiprocessing
import
hashlib
import
platform
import
paddle
import
paddle.fluid
as
fluid
import
six
...
...
paddlehub/finetune/regularizer.py
浏览文件 @
7715f42e
...
...
@@ -20,7 +20,6 @@ from __future__ import print_function
import
os
import
paddle.fluid
as
fluid
import
numpy
as
np
import
paddlehub
as
hub
...
...
paddlehub/finetune/strategy.py
浏览文件 @
7715f42e
...
...
@@ -17,9 +17,7 @@ from __future__ import absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
os
import
math
import
multiprocessing
import
paddle.fluid
as
fluid
...
...
paddlehub/module/manager.py
浏览文件 @
7715f42e
...
...
@@ -24,9 +24,7 @@ from functools import cmp_to_key
import
tarfile
from
paddlehub.common
import
utils
from
paddlehub.common
import
srv_utils
from
paddlehub.common.downloader
import
default_downloader
from
paddlehub.common.hub_server
import
default_hub_server
from
paddlehub.common.dir
import
MODULE_HOME
from
paddlehub.common.cml_utils
import
TablePrinter
from
paddlehub.module
import
module_desc_pb2
...
...
@@ -102,7 +100,7 @@ class LocalModuleManager(object):
module_dir
)
return
True
,
tips
,
self
.
modules_dict
[
module_name
]
search_result
=
hub
.
default_hub_server
.
get_module_url
(
search_result
=
hub
.
HubServer
()
.
get_module_url
(
module_name
,
version
=
module_version
,
extra
=
extra
)
name
=
search_result
.
get
(
'name'
,
None
)
url
=
search_result
.
get
(
'url'
,
None
)
...
...
@@ -111,10 +109,10 @@ class LocalModuleManager(object):
if
not
url
or
(
module_version
is
not
None
and
installed_module_version
!=
module_version
)
or
(
name
!=
module_name
):
if
default_hub_server
.
_server_check
()
is
False
:
if
hub
.
HubServer
()
.
_server_check
()
is
False
:
tips
=
"Request Hub-Server unsuccessfully, please check your network."
return
False
,
tips
,
None
module_versions_info
=
default_hub_server
.
search_module_info
(
module_versions_info
=
hub
.
HubServer
()
.
search_module_info
(
module_name
)
if
module_versions_info
is
not
None
and
len
(
module_versions_info
)
>
0
:
...
...
@@ -150,8 +148,6 @@ class LocalModuleManager(object):
tips
=
"Can't find module %s"
%
module_name
if
module_version
:
tips
+=
" with version %s"
%
module_version
module_tag
=
module_name
if
not
module_version
else
'%s-%s'
%
(
module_name
,
module_version
)
return
False
,
tips
,
None
result
,
tips
,
module_zip_file
=
default_downloader
.
download_file
(
...
...
paddlehub/module/module.py
浏览文件 @
7715f42e
...
...
@@ -37,7 +37,6 @@ from paddlehub.common.lock import lock
from
paddlehub.common.logger
import
logger
from
paddlehub.common.hub_server
import
CacheUpdater
from
paddlehub.module
import
module_desc_pb2
from
paddlehub.module
import
check_info_pb2
from
paddlehub.module.manager
import
default_module_manager
from
paddlehub.module.checker
import
ModuleChecker
from
paddlehub.module.signature
import
Signature
,
create_signature
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录