From 8ad6bd0f1b734e0c92540ecd88a9e624c35febb5 Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 17 Jan 2025 15:41:56 +0000 Subject: [PATCH] Stop mutating input dicts in audio classification pipeline (#35754) --- src/transformers/pipelines/audio_classification.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/transformers/pipelines/audio_classification.py b/src/transformers/pipelines/audio_classification.py index f6acbb3096e07d..b69b0a4a42398d 100644 --- a/src/transformers/pipelines/audio_classification.py +++ b/src/transformers/pipelines/audio_classification.py @@ -172,6 +172,7 @@ def preprocess(self, inputs): inputs = ffmpeg_read(inputs, self.feature_extractor.sampling_rate) if isinstance(inputs, dict): + inputs = inputs.copy() # So we don't mutate the original dictionary outside the pipeline # Accepting `"array"` which is the key defined in `datasets` for # better integration if not ("sampling_rate" in inputs and ("raw" in inputs or "array" in inputs)):