#4052 ValueError: The elements of the batch contain different keys. Cannot batch them ({'is_last', 'input_features', 'attentio

114.32* Posted at: 2 days ago 👁22

Traceback (most recent call last):
File "videotrans\process\stt_fun.py", line 585, in pipe_asr
File "transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "transformers\pipelines\pt_utils.py", line 271, in next

processed = self.infer(next(self.iterator), **self.params)

File "torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "torch\utils\data\dataloader.py", line 789, in _next_data

data = self._dataset_fetcher.fetch(index)  # may raise StopIteration

File "torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "transformers\pipelines\base.py", line 182, in inner

raise ValueError(

ValueError: The elements of the batch contain different keys. Cannot batch them ({'is_last', 'input_features', 'attention_mask'} != {'is_last', 'input_features', 'attention_mask', 'num_frames'})

Traceback (most recent call last):
File "videotrans\task\_only_one.py", line 44, in run
File "videotrans\task\trans_create.py", line 360, in recogn
File "videotrans\recognition\__init__.py", line 279, in run
File "videotrans\recognition\_base.py", line 143, in run
File "videotrans\recognition\_huggingface.py", line 38, in _exec
File "videotrans\recognition\_huggingface.py", line 63, in _pipe_asr
File "videotrans\configure\_base.py", line 289, in _new_process
RuntimeError: Traceback (most recent call last):
File "videotrans\process\stt_fun.py", line 585, in pipe_asr
File "transformers\pipelines\pt_utils.py", line 126, in next

item = next(self.iterator)

File "transformers\pipelines\pt_utils.py", line 271, in next

processed = self.infer(next(self.iterator), **self.params)

File "torch\utils\data\dataloader.py", line 733, in next

data = self._next_data()

File "torch\utils\data\dataloader.py", line 789, in _next_data

data = self._dataset_fetcher.fetch(index)  # may raise StopIteration

File "torch\utils\data\_utils\fetch.py", line 43, in fetch

return self.collate_fn(data)

File "transformers\pipelines\base.py", line 182, in inner

raise ValueError(

ValueError: The elements of the batch contain different keys. Cannot batch them ({'is_last', 'input_features', 'attention_mask'} != {'is_last', 'input_features', 'attention_mask', 'num_frames'})


=
system:Windows-10-10.0.26200-SP0
version:v3.98
frozen:True
language:zh
root_dir:C:/Users/bb929/Downloads/win-pyvideotrans-v3.98-0410

1 Replies

这是由于使用了 HuggingFace ASR 渠道时,模型或数据处理管道内部出现了批次数据键值不一致的错误。

解决方案:

  1. 切换语音识别渠道:暂时避免使用 HuggingFace_ASR 渠道。建议改用 faster-whisper(本地)openai-whisper(本地) 渠道,并选择 large-v3 模型。
  2. 检查模型选择:如果必须使用 HuggingFace 模型,请确保在 HuggingFace_ASR 渠道中选择了正确的、与视频语言匹配的模型(例如,中文视频可选择 qwen/qwen2-audio-7b,日语视频可选择 kotoba-whisper)。
  3. 配置网络代理:如果模型需要从 HuggingFace 下载,而您位于中国大陆,请在主界面的“网络代理地址”中填写有效的代理地址(如 http://127.0.0.1:10808),或手动下载模型文件到 models/ 目录。
  4. 更新软件:确保您使用的是最新版本的 pyVideoTrans(当前为 v3.98-0410)。如果是从旧版本升级而来,请重新下载完整包覆盖。

如果问题依旧,请提供软件安装目录下 logs/ 文件夹中最新日志文件的底部约30行内容,以便进一步分析。

请查阅相关文档:

Post Your Reply
Open source and free maintenance is not easy. If this project is helpful to you, please consider making a small donation to help the project continue to maintain and update.

Related resource

Similar issues already exist