Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
333ccc5b
Unverified
提交
333ccc5b
authored
3月 24, 2021
作者:
Glenn Jocher
提交者:
GitHub
3月 24, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
YOLOv5 PyTorch Hub models >> check_requirements() (#2592)
Improved user-feedback following requirements auto-update.
上级
75feeb79
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
3 行删除
+14
-3
general.py
utils/general.py
+14
-3
没有找到文件。
utils/general.py
浏览文件 @
333ccc5b
...
@@ -52,6 +52,11 @@ def isdocker():
...
@@ -52,6 +52,11 @@ def isdocker():
return
Path
(
'/workspace'
)
.
exists
()
# or Path('/.dockerenv').exists()
return
Path
(
'/workspace'
)
.
exists
()
# or Path('/.dockerenv').exists()
def
emojis
(
str
=
''
):
# Return platform-dependent emoji-safe version of string
return
str
.
encode
()
.
decode
(
'ascii'
,
'ignore'
)
if
platform
.
system
()
==
'Windows'
else
str
def
check_online
():
def
check_online
():
# Check internet connectivity
# Check internet connectivity
import
socket
import
socket
...
@@ -79,7 +84,7 @@ def check_git_status():
...
@@ -79,7 +84,7 @@ def check_git_status():
f
"Use 'git pull' to update or 'git clone {url}' to download latest."
f
"Use 'git pull' to update or 'git clone {url}' to download latest."
else
:
else
:
s
=
f
'up to date with {url} ✅'
s
=
f
'up to date with {url} ✅'
print
(
s
.
encode
()
.
decode
(
'ascii'
,
'ignore'
)
if
platform
.
system
()
==
'Windows'
else
s
)
# emoji-safe
print
(
emojis
(
s
)
)
# emoji-safe
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
...
@@ -93,14 +98,20 @@ def check_requirements(file='requirements.txt', exclude=()):
...
@@ -93,14 +98,20 @@ def check_requirements(file='requirements.txt', exclude=()):
print
(
f
"{prefix} {file.resolve()} not found, check failed."
)
print
(
f
"{prefix} {file.resolve()} not found, check failed."
)
return
return
n
=
0
# number of packages updates
requirements
=
[
f
'{x.name}{x.specifier}'
for
x
in
pkg
.
parse_requirements
(
file
.
open
())
if
x
.
name
not
in
exclude
]
requirements
=
[
f
'{x.name}{x.specifier}'
for
x
in
pkg
.
parse_requirements
(
file
.
open
())
if
x
.
name
not
in
exclude
]
for
r
in
requirements
:
for
r
in
requirements
:
try
:
try
:
pkg
.
require
(
r
)
pkg
.
require
(
r
)
except
Exception
as
e
:
# DistributionNotFound or VersionConflict if requirements not met
except
Exception
as
e
:
# DistributionNotFound or VersionConflict if requirements not met
print
(
f
"{prefix} {e.req} not found and is required by YOLOv5, attempting auto-install..."
)
n
+=
1
print
(
f
"{prefix} {e.req} not found and is required by YOLOv5, attempting auto-update..."
)
print
(
subprocess
.
check_output
(
f
"pip install '{e.req}'"
,
shell
=
True
)
.
decode
())
print
(
subprocess
.
check_output
(
f
"pip install '{e.req}'"
,
shell
=
True
)
.
decode
())
print
(
f
'Please restart runtime or rerun command for update to take effect.'
)
if
n
:
# if packages updated
s
=
f
"{prefix} {n} package{'s' * (n > 1)} updated per {file.resolve()}
\n
"
\
f
"{prefix} ⚠️ {colorstr('bold', 'Restart runtime or rerun command for updates to take effect')}
\n
"
print
(
emojis
(
s
))
# emoji-safe
def
check_img_size
(
img_size
,
s
=
32
):
def
check_img_size
(
img_size
,
s
=
32
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论