Spaces:
Sleeping
Sleeping
Commit ·
997c378
1
Parent(s): eb9c81a
fixes
Browse files- requirements.txt +0 -1
- src/components/losses.py +0 -23
requirements.txt
CHANGED
|
@@ -11,7 +11,6 @@ scikit-learn
|
|
| 11 |
onnxruntime
|
| 12 |
pandas
|
| 13 |
seaborn
|
| 14 |
-
speechbrain
|
| 15 |
transformers
|
| 16 |
datasets
|
| 17 |
# --------- pytorch --------- #
|
|
|
|
| 11 |
onnxruntime
|
| 12 |
pandas
|
| 13 |
seaborn
|
|
|
|
| 14 |
transformers
|
| 15 |
datasets
|
| 16 |
# --------- pytorch --------- #
|
src/components/losses.py
CHANGED
|
@@ -6,7 +6,6 @@ import torch.nn.functional as F
|
|
| 6 |
from audiotools import AudioSignal
|
| 7 |
from audiotools import STFTParams
|
| 8 |
from torch import nn
|
| 9 |
-
from speechbrain.lobes.models.huggingface_transformers.hubert import HuBERT
|
| 10 |
|
| 11 |
|
| 12 |
class L1Loss(nn.L1Loss):
|
|
@@ -433,25 +432,3 @@ class LossPED(nn.Module):
|
|
| 433 |
"energy_loss": energy_loss * self.energy_loss_weight,
|
| 434 |
}
|
| 435 |
return loss
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
class HuBERTLoss(nn.Module):
|
| 439 |
-
"""Loss Computation for HuBERT model using MSELoss"""
|
| 440 |
-
|
| 441 |
-
def __init__(self, loss_fn : typing.Callable = nn.MSELoss(), device = "cuda"):
|
| 442 |
-
super().__init__()
|
| 443 |
-
model_hub = "facebook/hubert-base-ls960"
|
| 444 |
-
save_path = "pretrained_models/hubert-base-ls960"
|
| 445 |
-
self.model = HuBERT(model_hub, save_path).to(device)
|
| 446 |
-
self.loss_fn = loss_fn
|
| 447 |
-
|
| 448 |
-
def forward(self, inputs, targets):
|
| 449 |
-
if isinstance(inputs, AudioSignal):
|
| 450 |
-
inputs = getattr(inputs, "audio_data")
|
| 451 |
-
targets = getattr(targets, "audio_data")
|
| 452 |
-
|
| 453 |
-
inputs = self.model(inputs.squeeze())
|
| 454 |
-
targets = self.model(targets.squeeze())
|
| 455 |
-
|
| 456 |
-
loss = self.loss_fn(inputs, targets)
|
| 457 |
-
return loss
|
|
|
|
| 6 |
from audiotools import AudioSignal
|
| 7 |
from audiotools import STFTParams
|
| 8 |
from torch import nn
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
class L1Loss(nn.L1Loss):
|
|
|
|
| 432 |
"energy_loss": energy_loss * self.energy_loss_weight,
|
| 433 |
}
|
| 434 |
return loss
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|