Skip to content

Commit

Permalink
trigger actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Flynn authored and jonflynng committed Oct 29, 2024
1 parent a391639 commit 1ff4a6a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"deepspeed>=0.9.3",
"diffusers",
"dill<0.3.5",
"einops",
"evaluate>=0.2.0",
"faiss-cpu",
"fastapi",
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2153,10 +2153,10 @@
)
_import_structure["models.encodec"].extend(
[
"EncodecDiscriminator",
"EncodecDiscriminatorConfig",
"EncodecModel",
"EncodecPreTrainedModel",
"EncodecDiscriminatorConfig",
"EncodecDiscriminator",
]
)
_import_structure["models.encoder_decoder"].append("EncoderDecoderModel")
Expand Down
1 change: 1 addition & 0 deletions src/transformers/dependency_versions_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"deepspeed": "deepspeed>=0.9.3",
"diffusers": "diffusers",
"dill": "dill<0.3.5",
"einops": "einops",
"evaluate": "evaluate>=0.2.0",
"faiss-cpu": "faiss-cpu",
"fastapi": "fastapi",
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/models/encodec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"configuration_encodec": ["EncodecConfig"],
"feature_extraction_encodec": ["EncodecFeatureExtractor"],
"loss_encodec": [
"Balancer",
"compute_discriminator_loss",
"compute_generator_adv_loss",
"compute_feature_matching_loss",
"Balancer",
"compute_generator_adv_loss",
],
}

Expand Down
2 changes: 1 addition & 1 deletion src/transformers/models/encodec/modeling_encodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ def compute_loss(self, real_audio, fake_audio):
g_adv_loss += -fake_logit.mean()
g_adv_loss /= self.num_discriminators

# Feature matching loss
# feature matching loss
fm_loss = 0
for real_feat, fake_feat in zip(real_features, fake_features):
for real_f, fake_f in zip(real_feat, fake_feat):
Expand Down
5 changes: 4 additions & 1 deletion tests/models/encodec/test_modeling_encodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
compute_feature_matching_loss,
compute_generator_adv_loss,
)
from transformers.testing_utils import is_torch_available, require_torch, slow, torch_device
from transformers.testing_utils import is_torch_available, require_torch, require_torchaudio, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
Expand Down Expand Up @@ -183,6 +183,7 @@ def test_balancer_basic(self):
assert torch.allclose(x.grad, torch.tensor(0.0)), x.grad

@slow
@require_torchaudio
def test_training_with_discriminator(self):
model_id = "facebook/encodec_24khz"
model = EncodecModel.from_pretrained(model_id).to(torch_device)
Expand Down Expand Up @@ -311,6 +312,7 @@ def test_training_with_discriminator(self):
print(f"Total generator loss (before balancing): {total_gen_loss:.4f}\n")

@slow
@require_torchaudio
def test_reconstruction_loss(self):
model_id = "facebook/encodec_24khz"
model = EncodecModel.from_pretrained(model_id).to(torch_device)
Expand Down Expand Up @@ -354,6 +356,7 @@ def test_reconstruction_loss(self):
print(f"Spectrogram MAE: {spec_mae.item()}")

@slow
@require_torchaudio
def test_gradients_exist(self):
model_id = "facebook/encodec_24khz"
model = EncodecModel.from_pretrained(model_id).to(torch_device)
Expand Down

0 comments on commit 1ff4a6a

Please sign in to comment.