Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yolov5
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Administrator
yolov5
Commits
d5289b54
Unverified
提交
d5289b54
authored
12月 18, 2020
作者:
Glenn Jocher
提交者:
GitHub
12月 18, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean_str() function addition (#1674)
* clean_str() function addition * cleanup * add euro symbol € * add closing exclamation (spanish) * cleanup
上级
7e161d97
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
13 行增加
和
7 行删除
+13
-7
detect.py
detect.py
+5
-4
datasets.py
utils/datasets.py
+2
-2
general.py
utils/general.py
+6
-1
没有找到文件。
detect.py
浏览文件 @
d5289b54
...
...
@@ -81,12 +81,13 @@ def detect(save_img=False):
# Process detections
for
i
,
det
in
enumerate
(
pred
):
# detections per image
if
webcam
:
# batch_size >= 1
p
,
s
,
im0
,
frame
=
Path
(
path
[
i
])
,
'
%
g: '
%
i
,
im0s
[
i
]
.
copy
(),
dataset
.
count
p
,
s
,
im0
,
frame
=
path
[
i
]
,
'
%
g: '
%
i
,
im0s
[
i
]
.
copy
(),
dataset
.
count
else
:
p
,
s
,
im0
,
frame
=
Path
(
path
)
,
''
,
im0s
,
getattr
(
dataset
,
'frame'
,
0
)
p
,
s
,
im0
,
frame
=
path
,
''
,
im0s
,
getattr
(
dataset
,
'frame'
,
0
)
save_path
=
str
(
save_dir
/
p
.
name
)
txt_path
=
str
(
save_dir
/
'labels'
/
p
.
stem
)
+
(
''
if
dataset
.
mode
==
'image'
else
f
'_{frame}'
)
p
=
Path
(
p
)
# to Path
save_path
=
str
(
save_dir
/
p
.
name
)
# img.jpg
txt_path
=
str
(
save_dir
/
'labels'
/
p
.
stem
)
+
(
''
if
dataset
.
mode
==
'image'
else
f
'_{frame}'
)
# img.txt
s
+=
'
%
gx
%
g '
%
img
.
shape
[
2
:]
# print string
gn
=
torch
.
tensor
(
im0
.
shape
)[[
1
,
0
,
1
,
0
]]
# normalization gain whwh
if
len
(
det
):
...
...
utils/datasets.py
浏览文件 @
d5289b54
...
...
@@ -19,7 +19,7 @@ from PIL import Image, ExifTags
from
torch.utils.data
import
Dataset
from
tqdm
import
tqdm
from
utils.general
import
xyxy2xywh
,
xywh2xyxy
from
utils.general
import
xyxy2xywh
,
xywh2xyxy
,
clean_str
from
utils.torch_utils
import
torch_distributed_zero_first
# Parameters
...
...
@@ -267,7 +267,7 @@ class LoadStreams: # multiple IP or RTSP cameras
n
=
len
(
sources
)
self
.
imgs
=
[
None
]
*
n
self
.
sources
=
sources
self
.
sources
=
[
clean_str
(
x
)
for
x
in
sources
]
# clean source names for later
for
i
,
s
in
enumerate
(
sources
):
# Start the thread to read frames from the video stream
print
(
'
%
g/
%
g:
%
s... '
%
(
i
+
1
,
n
,
s
),
end
=
''
)
...
...
utils/general.py
浏览文件 @
d5289b54
...
...
@@ -2,6 +2,7 @@
import
glob
import
logging
import
math
import
os
import
platform
import
random
...
...
@@ -11,7 +12,6 @@ import time
from
pathlib
import
Path
import
cv2
import
math
import
numpy
as
np
import
torch
import
torchvision
...
...
@@ -97,6 +97,11 @@ def make_divisible(x, divisor):
return
math
.
ceil
(
x
/
divisor
)
*
divisor
def
clean_str
(
s
):
# Cleans a string by replacing special characters with underscore _
return
re
.
sub
(
pattern
=
"[|@#!¡·$€
%
&()=?¿^*;:,¨´><+]"
,
repl
=
"_"
,
string
=
s
)
def
labels_to_class_weights
(
labels
,
nc
=
80
):
# Get class weights (inverse frequency) from training labels
if
labels
[
0
]
is
None
:
# no labels loaded
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论