Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Giving dictionary to Audio Classification Pipeline overwrites dictionary data #35740

Closed
2 of 4 tasks
wilke0818 opened this issue Jan 16, 2025 · 2 comments · Fixed by #35754
Closed
2 of 4 tasks

Giving dictionary to Audio Classification Pipeline overwrites dictionary data #35740

wilke0818 opened this issue Jan 16, 2025 · 2 comments · Fixed by #35754
Labels

Comments

@wilke0818
Copy link

System Info

  • transformers version: 4.48.0
  • Platform: macOS-14.6-arm64-arm-64bit
  • Python version: 3.12.4
  • Huggingface_hub version: 0.27.1
  • Safetensors version: 0.5.2
  • Accelerate version: 1.2.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.5.1 (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using distributed or parallel set-up in script?: None/NA

Who can help?

@Rocketknight1

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

from transformers import pipeline
import torch
import numpy as np

model_name = 'audeering/wav2vec2-large-robust-12-ft-emotion-msp-dim'
#model_name = 'pollner/distilhubert-finetuned-ravdess'
top_k = 5
device = 'cuda' if torch.cuda.is_available() else 'cpu'
classification_pipeline = pipeline(
                "audio-classification",
                model=model_name,
                # top_k=top_k, 
                # function_to_apply='none',
                device=device,
            )

# dummy signal
sampling_rate = 16000
signal = np.zeros((sampling_rate), dtype=np.float32)

input_signal = {
    'array': signal,
    'sampling_rate': sampling_rate
}
print(input_signal)
print(classification_pipeline(input_signal))
print(input_signal)

Expected behavior

I would imagine, but could be wrong, that the internal logic should not be mutating inputs, especially because this occurs when inputting a dictionary but not when just inputting a numpy array.

@Rocketknight1
Copy link
Member

Yes, thank you for the report! A fix is open at #35754

@Rocketknight1
Copy link
Member

@wilke0818 a fix has been merged! Can you install the latest version from main and confirm that it fixes the issue for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants