Skip to content

Commit 43d19eb

Browse files
committed
fix(dml): train extract_f0_print error
ModuleNotFoundError: No module named 'torch.privateuseone' due to new prosess
1 parent 7fa1220 commit 43d19eb

13 files changed

Lines changed: 50 additions & 39 deletions

File tree

infer/modules/train/extract_f0_print.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import sys
33
import traceback
44
from pathlib import Path
5+
import importlib.util
56

67
from dotenv import load_dotenv
78

@@ -38,6 +39,8 @@ def printt(strr):
3839
device = sys.argv[4]
3940
is_half = sys.argv[5] == "True"
4041

42+
if importlib.util.find_spec("torch_directml") is not None:
43+
import torch_directml # use side effect
4144

4245
class FeatureInput(object):
4346
def __init__(self, is_half: bool, device="cpu", samplerate=16000, hop_size=160):

rvc/f0/f0.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ def __init__(
1111
f0_min=50,
1212
f0_max=1100,
1313
sampling_rate=44100,
14-
device: Optional[str] = None,
14+
device: Optional[Union[str, torch.device]] = None,
1515
):
1616
self.hop_length = hop_length
1717
self.f0_min = f0_min
1818
self.f0_max = f0_max
1919
self.sampling_rate = sampling_rate
20-
if device is None:
21-
device = "cuda:0" if torch.cuda.is_available() else "cpu"
20+
if not device:
21+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
2222
self.device = device
2323

2424
def compute_f0(

rvc/f0/mel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional
1+
from typing import Optional, Union
22

33
import torch
44
import numpy as np
@@ -17,9 +17,9 @@ def __init__(
1717
hop_length: int,
1818
n_fft: Optional[int] = None,
1919
mel_fmin: int = 0,
20-
mel_fmax: int = None,
20+
mel_fmax: Optional[int] = None,
2121
clamp: float = 1e-5,
22-
device=torch.device("cpu"),
22+
device: Union[str, torch.device] = torch.device("cpu"),
2323
):
2424
super().__init__()
2525
if n_fft is None:

rvc/f0/rmvpe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from io import BytesIO
22
import os
3-
from typing import Any, Optional, Union
3+
from typing import Optional, Union
44

55
import numpy as np
66
import torch

rvc/layers/attentions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def __init__(
1212
channels: int,
1313
out_channels: int,
1414
n_heads: int,
15+
window_size: int,
1516
p_dropout: float = 0.0,
16-
window_size: Optional[int] = None,
1717
heads_share: bool = True,
1818
block_length: Optional[int] = None,
1919
proximal_bias: bool = False,

rvc/layers/encoders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def __init__(
4242
hidden_channels,
4343
hidden_channels,
4444
n_heads,
45+
window_size,
4546
p_dropout=p_dropout,
46-
window_size=window_size,
4747
)
4848
)
4949
self.norm_layers_1.append(LayerNorm(hidden_channels))
@@ -121,7 +121,7 @@ def __init__(
121121
def __call__(
122122
self,
123123
phone: torch.Tensor,
124-
pitch: torch.Tensor,
124+
pitch: Optional[torch.Tensor],
125125
lengths: torch.Tensor,
126126
skip_head: Optional[int] = None,
127127
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
@@ -135,7 +135,7 @@ def __call__(
135135
def forward(
136136
self,
137137
phone: torch.Tensor,
138-
pitch: torch.Tensor,
138+
pitch: Optional[torch.Tensor],
139139
lengths: torch.Tensor,
140140
skip_head: Optional[int] = None,
141141
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:

rvc/layers/generators.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(
4646

4747
self.resblocks = nn.ModuleList()
4848
resblock_module = ResBlock1 if resblock == "1" else ResBlock2
49+
ch = 0
4950
for i in range(len(self.ups)):
5051
ch = upsample_initial_channel // (2 ** (i + 1))
5152
for k, d in zip(resblock_kernel_sizes, resblock_dilation_sizes):

rvc/layers/norms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(
3030
dilation_rate: int,
3131
n_layers: int,
3232
gin_channels: int = 0,
33-
p_dropout: int = 0,
33+
p_dropout: float = 0,
3434
):
3535
super(WN, self).__init__()
3636
assert kernel_size % 2 == 1

rvc/layers/nsf.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, List
1+
from typing import Optional, List, Union
22
import math
33

44
import torch
@@ -83,7 +83,7 @@ def __init__(
8383
self.conv_pre = Conv1d(
8484
initial_channel, upsample_initial_channel, 7, 1, padding=3
8585
)
86-
resblock = ResBlock1 if resblock == "1" else ResBlock2
86+
resblockcls = ResBlock1 if resblock == "1" else ResBlock2
8787

8888
self.ups = nn.ModuleList()
8989
for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
@@ -114,12 +114,13 @@ def __init__(
114114
self.noise_convs.append(Conv1d(1, c_cur, kernel_size=1))
115115

116116
self.resblocks = nn.ModuleList()
117+
ch = 0
117118
for i in range(len(self.ups)):
118-
ch: int = upsample_initial_channel // (2 ** (i + 1))
119+
ch = upsample_initial_channel // (2 ** (i + 1))
119120
for j, (k, d) in enumerate(
120121
zip(resblock_kernel_sizes, resblock_dilation_sizes)
121122
):
122-
self.resblocks.append(resblock(ch, k, d))
123+
self.resblocks.append(resblockcls(ch, k, d))
123124

124125
self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
125126
self.ups.apply(call_weight_data_normal_if_Conv)

rvc/layers/residuals.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __init__(
2020
self,
2121
channels: int,
2222
kernel_size: int = 3,
23-
dilation: List[int] = (1, 3, 5),
23+
dilation: List[int] = [1, 3, 5],
2424
):
2525
super(ResBlock1, self).__init__()
2626

@@ -117,7 +117,7 @@ def __init__(
117117
self,
118118
channels: int,
119119
kernel_size=3,
120-
dilation: List[int] = (1, 3),
120+
dilation: List[int] = [1, 3],
121121
):
122122
super(ResBlock2, self).__init__()
123123
self.convs = nn.ModuleList()
@@ -182,7 +182,7 @@ def __init__(
182182
kernel_size: int,
183183
dilation_rate: int,
184184
n_layers: int,
185-
p_dropout: int = 0,
185+
p_dropout: float = 0,
186186
gin_channels: int = 0,
187187
mean_only: bool = False,
188188
):

0 commit comments

Comments
 (0)