Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mrywhh
Real-Time-Voice-Cloning
提交
8077b500
R
Real-Time-Voice-Cloning
项目概览
mrywhh
/
Real-Time-Voice-Cloning
落后 Fork 源项目 12 个版本
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Real-Time-Voice-Cloning
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8077b500
编写于
5月 04, 2019
作者:
C
Corentin Jemine
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Great speedup on the computation of the loss
上级
71256622
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
14 addition
and
12 deletion
+14
-12
SV2TTS/encoder/model.py
SV2TTS/encoder/model.py
+6
-7
SV2TTS/encoder/train.py
SV2TTS/encoder/train.py
+7
-4
SV2TTS/encoder/ui/visualizations.py
SV2TTS/encoder/ui/visualizations.py
+1
-1
未找到文件。
SV2TTS/encoder/model.py
浏览文件 @
8077b500
...
...
@@ -80,18 +80,17 @@ class SpeakerEncoder(nn.Module):
centroids_excl
=
centroids_excl
.
clone
()
/
torch
.
norm
(
centroids_excl
,
dim
=
2
,
keepdim
=
True
)
# Similarity matrix
sim_matrix
=
torch
.
zeros
(
speakers_per_batch
*
utterances_per_speaker
,
sim_matrix
=
torch
.
zeros
(
speakers_per_batch
,
utterances_per_speaker
,
speakers_per_batch
).
to
(
self
.
loss_device
)
for
j
in
range
(
speakers_per_batch
):
for
i
in
range
(
utterances_per_speaker
):
ji
=
j
*
utterances_per_speaker
+
i
for
k
in
range
(
speakers_per_batch
):
centroid
=
centroids_excl
[
j
,
i
]
if
j
==
k
else
centroids_incl
[
k
]
# The cosine similarity is the dot product when vectors are normalized
sim_matrix
[
ji
,
k
]
=
torch
.
dot
(
embeds
[
j
,
i
],
centroid
)
centroid
=
centroids_excl
[
j
]
if
j
==
k
else
centroids_incl
[
k
]
sim_matrix
[
j
,
:,
k
]
=
(
embeds
[
j
]
*
centroid
).
sum
(
dim
=
1
)
sim_matrix
=
sim_matrix
*
self
.
similarity_weight
+
self
.
similarity_bias
# Loss
sim_matrix
=
sim_matrix
.
view
((
speakers_per_batch
*
utterances_per_speaker
,
speakers_per_batch
))
ground_truth
=
np
.
repeat
(
np
.
arange
(
speakers_per_batch
),
utterances_per_speaker
)
target
=
torch
.
from_numpy
(
ground_truth
).
long
().
to
(
self
.
loss_device
)
loss
=
self
.
loss_fn
(
sim_matrix
,
target
)
...
...
SV2TTS/encoder/train.py
浏览文件 @
8077b500
...
...
@@ -61,10 +61,13 @@ def train(run_id: str, clean_data_root: Path, models_dir: Path, vis_every: int,
# Forward pass
inputs
=
torch
.
from_numpy
(
speaker_batch
.
data
).
to
(
device
)
torch
.
cuda
.
synchronize
(
device
)
profiler
.
tick
(
"Data to %s"
%
device
)
embeds
=
model
(
inputs
).
to
(
loss_device
)
embeds
=
model
(
inputs
)
torch
.
cuda
.
synchronize
(
device
)
profiler
.
tick
(
"Forward pass"
)
loss
,
eer
=
model
.
loss
(
embeds
.
view
((
speakers_per_batch
,
utterances_per_speaker
,
-
1
)))
embeds_loss
=
embeds
.
view
((
speakers_per_batch
,
utterances_per_speaker
,
-
1
)).
to
(
loss_device
)
loss
,
eer
=
model
.
loss
(
embeds_loss
)
profiler
.
tick
(
"Loss"
)
# Backward pass
...
...
@@ -84,8 +87,8 @@ def train(run_id: str, clean_data_root: Path, models_dir: Path, vis_every: int,
print
(
"Drawing and saving projections (step %d)"
%
step
)
backup_dir
.
mkdir
(
exist_ok
=
True
)
projection_fpath
=
backup_dir
.
joinpath
(
"%s_umap_%06d.png"
%
(
run_id
,
step
))
embeds
_numpy
=
embeds
.
detach
().
numpy
()
vis
.
draw_projections
(
embeds
_numpy
,
utterances_per_speaker
,
step
,
projection_fpath
)
embeds
=
embeds
.
detach
().
cpu
().
numpy
()
vis
.
draw_projections
(
embeds
,
utterances_per_speaker
,
step
,
projection_fpath
)
vis
.
save
()
# Overwrite the latest version of the model
...
...
SV2TTS/encoder/ui/visualizations.py
浏览文件 @
8077b500
...
...
@@ -45,7 +45,7 @@ class Visualizations:
except
ConnectionError
:
raise
Exception
(
"No visdom server detected. Run the command
\"
visdom
\"
in your CLI to "
"start it."
)
webbrowser
.
open
(
"http://localhost:8097/env/"
+
self
.
env_name
)
#
webbrowser.open("http://localhost:8097/env/" + self.env_name)
self
.
loss_win
=
None
self
.
eer_win
=
None
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录