Skip to content

Commit

Permalink
more propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchit-gandhi committed Jul 2, 2024
1 parent 03f9a73 commit fe516a7
Show file tree
Hide file tree
Showing 38 changed files with 71 additions and 213 deletions.
4 changes: 1 addition & 3 deletions src/transformers/commands/pt_to_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,7 @@ def get_inputs(self, pt_model, tf_dummy_inputs, config):
"""

def _get_audio_input():
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
speech_samples = ds.sort("id").select(range(2))[:2]["audio"]
raw_samples = [x["array"] for x in speech_samples]
return raw_samples
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ def test_double_precision_pad(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
4 changes: 1 addition & 3 deletions tests/models/clap/test_feature_extraction_clap.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ def test_double_precision_pad(self):

# Copied from tests.models.whisper.test_feature_extraction_whisper.WhisperFeatureExtractionTest._load_datasamples
def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
16 changes: 4 additions & 12 deletions tests/models/clap/test_modeling_clap.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,7 @@ def test_integration_unfused(self):
"repeat": 0.0023,
}

librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
audio_sample = librispeech_dummy[-1]

model_id = "laion/clap-htsat-unfused"
Expand All @@ -694,9 +692,7 @@ def test_integration_fused(self):
"pad": -0.000379,
}

librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
audio_sample = librispeech_dummy[-1]

model_id = "laion/clap-htsat-fused"
Expand All @@ -723,9 +719,7 @@ def test_batched_fused(self):
"pad": 0.0006,
}

librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
audio_samples = [sample["array"] for sample in librispeech_dummy[0:4]["audio"]]

model_id = "laion/clap-htsat-fused"
Expand All @@ -752,9 +746,7 @@ def test_batched_unfused(self):
"pad": 0.0019,
}

librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
audio_samples = [sample["array"] for sample in librispeech_dummy[0:4]["audio"]]

model_id = "laion/clap-htsat-unfused"
Expand Down
4 changes: 1 addition & 3 deletions tests/models/clvp/test_feature_extraction_clvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ def test_double_precision_pad(self):
self.assertTrue(pt_processed.input_features.dtype == torch.float32)

def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
ds = ds.cast_column("audio", Audio(sampling_rate=22050))
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]
Expand Down
8 changes: 2 additions & 6 deletions tests/models/clvp/test_modeling_clvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,7 @@ def get_config(self):
def prepare_config_and_inputs(self):
_, input_ids, attention_mask = self.clvp_encoder_tester.prepare_config_and_inputs()

ds = datasets.load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = datasets.load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
ds = ds.cast_column("audio", datasets.Audio(sampling_rate=22050))
_, audio, sr = ds.sort("id").select(range(1))[:1]["audio"][0].values()

Expand Down Expand Up @@ -555,9 +553,7 @@ def test_model_from_pretrained(self):
class ClvpIntegrationTest(unittest.TestCase):
def setUp(self):
self.text = "This is an example text."
ds = datasets.load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = datasets.load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
ds = ds.cast_column("audio", datasets.Audio(sampling_rate=22050))
_, self.speech_samples, self.sr = ds.sort("id").select(range(1))[:1]["audio"][0].values()

Expand Down
4 changes: 1 addition & 3 deletions tests/models/data2vec/test_modeling_data2vec_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ def test_compute_mask_indices_short_audio(self):
@slow
class Data2VecAudioModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/encodec/test_feature_extraction_encodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ def test_double_precision_pad(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
audio_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
12 changes: 3 additions & 9 deletions tests/models/encodec/test_modeling_encodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,7 @@ def test_integration_24kHz(self):
"1.5": [371955],
"24.0": [6659962],
}
librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
model_id = "facebook/encodec_24khz"

model = EncodecModel.from_pretrained(model_id).to(torch_device)
Expand Down Expand Up @@ -517,9 +515,7 @@ def test_integration_48kHz(self):
"3.0": [144259, 146765, 156435, 176871, 161971],
"24.0": [1568553, 1294948, 1306190, 1464747, 1663150],
}
librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
model_id = "facebook/encodec_48khz"

model = EncodecModel.from_pretrained(model_id).to(torch_device)
Expand Down Expand Up @@ -581,9 +577,7 @@ def test_batch_48kHz(self):
[85561, 81870, 76953, 48967, 79315, 85442, 81479, 107241],
],
}
librispeech_dummy = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
librispeech_dummy = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
model_id = "facebook/encodec_48khz"

model = EncodecModel.from_pretrained(model_id).to(torch_device)
Expand Down
4 changes: 1 addition & 3 deletions tests/models/hubert/test_modeling_hubert.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,9 +753,7 @@ class HubertModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/hubert/test_modeling_tf_hubert.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,7 @@ class TFHubertModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/pop2piano/test_feature_extraction_pop2piano.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ def test_call(self):
self.assertTrue(input_features.extrapolated_beatstep.ndim == 2)

def test_integration(self):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
speech_samples = ds.sort("id").select([0])["audio"]
input_speech = [x["array"] for x in speech_samples][0]
sampling_rate = [x["sampling_rate"] for x in speech_samples][0]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/pop2piano/test_processor_pop2piano.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ def test_save_load_pretrained_additional_features(self):

def get_inputs(self):
"""get inputs for both feature extractor and tokenizer"""
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
speech_samples = ds.sort("id").select([0])["audio"]
input_speech = [x["array"] for x in speech_samples][0]
sampling_rate = [x["sampling_rate"] for x in speech_samples][0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ def test_double_precision_pad(self):
self.assertTrue(pt_processed.input_features.dtype == torch.float32)

def _load_datasample(self, id):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_sample = ds.sort("id")[id]["audio"]["array"]

Expand Down
4 changes: 1 addition & 3 deletions tests/models/sew/test_modeling_sew.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ class SEWModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/sew_d/test_modeling_sew_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,7 @@ class SEWDModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ def test_double_precision_pad(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
4 changes: 1 addition & 3 deletions tests/models/speech_to_text/test_modeling_speech_to_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,7 @@ def default_processor(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,7 @@ def default_processor(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
4 changes: 1 addition & 3 deletions tests/models/speecht5/test_feature_extraction_speecht5.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,7 @@ def test_attention_mask_with_truncation_target(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
8 changes: 2 additions & 6 deletions tests/models/speecht5/test_modeling_speecht5.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,7 @@ def default_processor(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down Expand Up @@ -1771,9 +1769,7 @@ def default_processor(self):
def _load_datasamples(self, num_samples):
from datasets import load_dataset

ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]

Expand Down
4 changes: 1 addition & 3 deletions tests/models/unispeech/test_modeling_unispeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,7 @@ def test_model_from_pretrained(self):
@slow
class UniSpeechModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/unispeech_sat/test_modeling_unispeech_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -806,9 +806,7 @@ def test_model_from_pretrained(self):
@slow
class UniSpeechSatModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/univnet/test_feature_extraction_univnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,7 @@ def test_double_precision_pad(self):
self.assertTrue(pt_processed.input_features.dtype == torch.float32)

def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
ds = ds.cast_column("audio", Audio(sampling_rate=self.feat_extract_tester.sampling_rate))
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/univnet/test_modeling_univnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,7 @@ def tearDown(self):
torch.cuda.empty_cache()

def _load_datasamples(self, num_samples, sampling_rate=24000):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
ds = ds.cast_column("audio", Audio(sampling_rate=sampling_rate))
# automatic decoding with librispeech
speech_samples = ds.sort("id").select(range(num_samples))[:num_samples]["audio"]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/wav2vec2/test_modeling_flax_wav2vec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,7 @@ def test_sample_negatives_with_attn_mask(self):
@slow
class FlaxWav2Vec2ModelIntegrationTest(unittest.TestCase):
def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/wav2vec2/test_modeling_tf_wav2vec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,7 @@ def tearDown(self):
gc.collect()

def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
4 changes: 1 addition & 3 deletions tests/models/wav2vec2/test_modeling_wav2vec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,9 +1464,7 @@ def tearDown(self):
backend_empty_cache(torch_device)

def _load_datasamples(self, num_samples):
ds = load_dataset(
"hf-internal-testing/librispeech_asr_dummy", "clean", split="validation", trust_remote_code=True
)
ds = load_dataset("hf-internal-testing/librispeech_asr_dummy", "clean", split="validation")
# automatic decoding with librispeech
speech_samples = ds.sort("id").filter(
lambda x: x["id"] in [f"1272-141231-000{i}" for i in range(num_samples)]
Expand Down
Loading

0 comments on commit fe516a7

Please sign in to comment.