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

TypeError: _sanitize_parameters() got an unexpected keyword argument 'low_cpu_mem_usage' #31

Open
37llll opened this issue May 15, 2024 · 3 comments
Labels
question Further information is requested

Comments

@37llll
Copy link

37llll commented May 15, 2024

Describe the Question

Please provide a clear and concise description of what the que---------------------------------------------------------------------------

运行例子时遇到了这个错误,应该如何解决

TypeError Traceback (most recent call last)
Cell In[1], line 5
1 from parrots import SpeechRecognition
4 if name == 'main':
----> 5 m = SpeechRecognition('/app/pretrained_models/Belle-distilwhisper-large-v2-zh', low_cpu_mem_usage=False)
6 r = m.recognize_speech_from_file('./output.wav')
7 print('[提示] 语音识别结果:', r)

File /app/project/ASR-TTS/parrots/asr.py:81, in SpeechRecognition.init(self, model_name_or_path, use_cuda, cuda_device, max_new_tokens, chunk_length_s, batch_size, torch_dtype, use_flash_attention_2, language, **kwargs)
78 self.model.to(self.device)
80 self.processor = AutoProcessor.from_pretrained(model_name_or_path)
---> 81 self.pipe = pipeline(
82 "automatic-speech-recognition",
83 model=self.model,
84 tokenizer=self.processor.tokenizer,
85 feature_extractor=self.processor.feature_extractor,
86 device=self.device,
87 torch_dtype=torch_dtype,
88 max_new_tokens=max_new_tokens,
89 batch_size=batch_size,
90 chunk_length_s=chunk_length_s,
91 **kwargs
92 )
93 if language == 'zh':
94 self.pipe.model.config.forced_decoder_ids = (
95 self.pipe.tokenizer.get_decoder_prompt_ids(
96 language=language,
97 task="transcribe"
98 )
99 )

File ~/miniconda3/envs/speech_recognition/lib/python3.9/site-packages/transformers/pipelines/init.py:1108, in pipeline(task, model, config, tokenizer, feature_extractor, image_processor, framework, revision, use_fast, token, device, device_map, torch_dtype, trust_remote_code, model_kwargs, pipeline_class, **kwargs)
1105 if device is not None:
1106 kwargs["device"] = device
-> 1108 return pipeline_class(model=model, framework=framework, task=task, **kwargs)

File ~/miniconda3/envs/speech_recognition/lib/python3.9/site-packages/transformers/pipelines/automatic_speech_recognition.py:220, in AutomaticSpeechRecognitionPipeline.init(self, model, feature_extractor, tokenizer, decoder, device, torch_dtype, **kwargs)
217 else:
218 self.type = "ctc"
--> 220 super().init(model, tokenizer, feature_extractor, device=device, torch_dtype=torch_dtype, **kwargs)

File ~/miniconda3/envs/speech_recognition/lib/python3.9/site-packages/transformers/pipelines/base.py:894, in Pipeline.init(self, model, tokenizer, feature_extractor, image_processor, modelcard, framework, task, args_parser, device, torch_dtype, binary_output, **kwargs)
892 self._batch_size = kwargs.pop("batch_size", None)
893 self._num_workers = kwargs.pop("num_workers", None)
--> 894 self._preprocess_params, self._forward_params, self._postprocess_params = self._sanitize_parameters(**kwargs)
896 # Pipelines calling generate: if the tokenizer has a pad token but the model doesn't, set it in the
897 # forward params so that generate is aware of the pad token.
898 if (
899 self.tokenizer is not None
900 and self.model.can_generate()
901 and self.tokenizer.pad_token_id is not None
902 and self.model.generation_config.pad_token_id is None
903 ):

TypeError: _sanitize_parameters() got an unexpected keyword argument 'low_cpu_mem_usage'stion is.

@37llll 37llll added the question Further information is requested label May 15, 2024
@shibing624
Copy link
Owner

transformers啥版本?

@37llll
Copy link
Author

37llll commented May 17, 2024

transformers啥版本?
感谢回复
我的是transformers 4.40.2
请问需要的是什么版本

@shibing624
Copy link
Owner

1。最新版本的transformers是可以的;
2.保证gpu的显存足够,一般大于8GB;
3.low_cpu_mem_usage这个参数删掉。

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

No branches or pull requests

2 participants