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

return_dict in encodec is always set to True: #31642

Closed
kamilakesbi opened this issue Jun 26, 2024 · 2 comments · Fixed by #31646
Closed

return_dict in encodec is always set to True: #31642

kamilakesbi opened this issue Jun 26, 2024 · 2 comments · Fixed by #31646
Labels

Comments

@kamilakesbi
Copy link
Contributor

kamilakesbi commented Jun 26, 2024

System Info

  • transformers version: 4.42.0.dev0
  • Platform: Linux-5.4.0-166-generic-x86_64-with-glibc2.29
  • Python version: 3.8.10
  • Huggingface_hub version: 0.23.3
  • Safetensors version: 0.4.2
  • Accelerate version: 0.29.1
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.2.2+cu121 (True)
  • Tensorflow version (GPU?): 2.13.1 (True)
  • Flax version (CPU?/GPU?/TPU?): 0.7.0 (cpu)
  • Jax version: 0.4.13
  • JaxLib version: 0.4.13
  • Using distributed or parallel set-up in script?:
  • Using GPU in script?:
  • GPU type: NVIDIA DGX Display

Reproduction

from transformers import EncodecConfig, EncodecModel, EncodecFeatureExtractor
import numpy as np 
import torch

signal = [np.random.randn(1065473), np.random.randn(1065473) ]
signal = EncodecFeatureExtractor()(signal)

model = EncodecModel(EncodecConfig())

result = model(torch.tensor(signal.input_values), return_dict = True)
print(type(result))
result2 = model(torch.tensor(signal.input_values), return_dict = False)
print(type(result2))

will print <class 'transformers.models.encodec.modeling_encodec.EncodecOutput'> even when return_dict is set to False.

Expected behavior

It should return a tuple when return_dict is set to False.

cc @sanchit-gandhi

@AbhinavJangra29
Copy link

return_dict = return_dict or self.config.return_dict

@kamilakesbi
by default self.config.return_dict is true so the or condition is always maintained and the function returns a dict.

@kamilakesbi
Copy link
Contributor Author

Hi @AbhinavJangra29,

Thanks for spotting the issue. @jla524 has opened a PR to fix it!

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