Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
c1bed601
Unverified
提交
c1bed601
authored
9月 28, 2021
作者:
Diego Montes
提交者:
GitHub
9月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix `isascii()` method calls for python 3.6 (#4958)
* fix isascii for python3.6 * update comment with python 3.7 note Co-authored-by:
Glenn Jocher
<
glenn.jocher@ultralytics.com
>
上级
2993c3fa
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
8 行增加
和
3 行删除
+8
-3
general.py
utils/general.py
+5
-0
plots.py
utils/plots.py
+3
-3
没有找到文件。
utils/general.py
浏览文件 @
c1bed601
...
@@ -160,6 +160,11 @@ def is_pip():
...
@@ -160,6 +160,11 @@ def is_pip():
# Is file in a pip package?
# Is file in a pip package?
return
'site-packages'
in
Path
(
__file__
)
.
resolve
()
.
parts
return
'site-packages'
in
Path
(
__file__
)
.
resolve
()
.
parts
def
is_ascii
(
s
=
''
):
# Is string composed of all ASCII (no UTF) characters? (note str().isascii() introduced in python 3.7)
s
=
str
(
s
)
# convert list, tuple, None, etc. to str
return
len
(
s
.
encode
()
.
decode
(
'ascii'
,
'ignore'
))
==
len
(
s
)
def
is_chinese
(
s
=
'人工智能'
):
def
is_chinese
(
s
=
'人工智能'
):
# Is string composed of any Chinese characters?
# Is string composed of any Chinese characters?
...
...
utils/plots.py
浏览文件 @
c1bed601
...
@@ -17,7 +17,7 @@ import seaborn as sn
...
@@ -17,7 +17,7 @@ import seaborn as sn
import
torch
import
torch
from
PIL
import
Image
,
ImageDraw
,
ImageFont
from
PIL
import
Image
,
ImageDraw
,
ImageFont
from
utils.general
import
user_config_dir
,
is_chinese
,
xywh2xyxy
,
xyxy2xywh
from
utils.general
import
user_config_dir
,
is_
ascii
,
is_
chinese
,
xywh2xyxy
,
xyxy2xywh
from
utils.metrics
import
fitness
from
utils.metrics
import
fitness
# Settings
# Settings
...
@@ -68,7 +68,7 @@ class Annotator:
...
@@ -68,7 +68,7 @@ class Annotator:
# YOLOv5 Annotator for train/val mosaics and jpgs and detect/hub inference annotations
# YOLOv5 Annotator for train/val mosaics and jpgs and detect/hub inference annotations
def
__init__
(
self
,
im
,
line_width
=
None
,
font_size
=
None
,
font
=
'Arial.ttf'
,
pil
=
False
,
example
=
'abc'
):
def
__init__
(
self
,
im
,
line_width
=
None
,
font_size
=
None
,
font
=
'Arial.ttf'
,
pil
=
False
,
example
=
'abc'
):
assert
im
.
data
.
contiguous
,
'Image not contiguous. Apply np.ascontiguousarray(im) to Annotator() input images.'
assert
im
.
data
.
contiguous
,
'Image not contiguous. Apply np.ascontiguousarray(im) to Annotator() input images.'
self
.
pil
=
pil
or
not
example
.
isascii
(
)
or
is_chinese
(
example
)
self
.
pil
=
pil
or
not
is_ascii
(
example
)
or
is_chinese
(
example
)
if
self
.
pil
:
# use PIL
if
self
.
pil
:
# use PIL
self
.
im
=
im
if
isinstance
(
im
,
Image
.
Image
)
else
Image
.
fromarray
(
im
)
self
.
im
=
im
if
isinstance
(
im
,
Image
.
Image
)
else
Image
.
fromarray
(
im
)
self
.
draw
=
ImageDraw
.
Draw
(
self
.
im
)
self
.
draw
=
ImageDraw
.
Draw
(
self
.
im
)
...
@@ -80,7 +80,7 @@ class Annotator:
...
@@ -80,7 +80,7 @@ class Annotator:
def
box_label
(
self
,
box
,
label
=
''
,
color
=
(
128
,
128
,
128
),
txt_color
=
(
255
,
255
,
255
)):
def
box_label
(
self
,
box
,
label
=
''
,
color
=
(
128
,
128
,
128
),
txt_color
=
(
255
,
255
,
255
)):
# Add one xyxy box to image with label
# Add one xyxy box to image with label
if
self
.
pil
or
not
label
.
isascii
(
):
if
self
.
pil
or
not
is_ascii
(
label
):
self
.
draw
.
rectangle
(
box
,
width
=
self
.
lw
,
outline
=
color
)
# box
self
.
draw
.
rectangle
(
box
,
width
=
self
.
lw
,
outline
=
color
)
# box
if
label
:
if
label
:
w
,
h
=
self
.
font
.
getsize
(
label
)
# text width, height
w
,
h
=
self
.
font
.
getsize
(
label
)
# text width, height
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论