mirror of
https://github.com/Anjok07/ultimatevocalremovergui.git
synced 2025-01-31 12:23:51 +01:00
Add files via upload
More efficient MDX23C memory usage.
This commit is contained in:
parent
916358e32c
commit
54ba75acd9
24
separate.py
24
separate.py
@ -727,32 +727,20 @@ class SeperateMDXC(SeperateAttributes):
|
|||||||
mix = torch.cat([torch.zeros(2, C - H), mix, torch.zeros(2, pad_size + C - H)], 1)
|
mix = torch.cat([torch.zeros(2, C - H), mix, torch.zeros(2, pad_size + C - H)], 1)
|
||||||
mix = mix.to(self.device)
|
mix = mix.to(self.device)
|
||||||
|
|
||||||
chunks = []
|
chunks = mix.unfold(1, C, H).transpose(0, 1)
|
||||||
i = 0
|
batches = [chunks[i : i + batch_size] for i in range(0, len(chunks), batch_size)]
|
||||||
while i + C <= mix.shape[1]:
|
|
||||||
chunks.append(mix[:, i:i + C])
|
|
||||||
i += H
|
|
||||||
chunks = torch.stack(chunks)
|
|
||||||
|
|
||||||
batches = []
|
X = torch.zeros(S, *mix.shape).to(self.device) if S > 1 else torch.zeros_like(mix)
|
||||||
i = 0
|
|
||||||
while i < len(chunks):
|
|
||||||
batches.append(chunks[i:i + batch_size])
|
|
||||||
i = i + batch_size
|
|
||||||
|
|
||||||
X = torch.zeros(S, 2, C - H) if S > 1 else torch.zeros(2, C - H)
|
|
||||||
X = X.to(self.device)
|
|
||||||
|
|
||||||
#with torch.cuda.amp.autocast():
|
#with torch.cuda.amp.autocast():
|
||||||
with torch.no_grad():
|
with torch.no_grad():
|
||||||
|
cnt = 0
|
||||||
for batch in batches:
|
for batch in batches:
|
||||||
self.running_inference_progress_bar(len(batches))
|
self.running_inference_progress_bar(len(batches))
|
||||||
x = model(batch)
|
x = model(batch)
|
||||||
for w in x:
|
for w in x:
|
||||||
a = X[..., :-(C - H)]
|
X[..., cnt * H : cnt * H + C] += w
|
||||||
b = X[..., -(C - H):] + w[..., :(C - H)]
|
cnt += 1
|
||||||
c = w[..., (C - H):]
|
|
||||||
X = torch.cat([a, b, c], -1)
|
|
||||||
|
|
||||||
estimated_sources = X[..., C - H:-(pad_size + C - H)] / N
|
estimated_sources = X[..., C - H:-(pad_size + C - H)] / N
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user