#2402 Traceback (most recent call last): File "/Volumes/Ventoy/video/index-tts/webui.py", line 51, infrom indextts.infer_v2 i

117.181* Posted at: 3 hours ago 👁9

Traceback (most recent call last):
File "/Volumes/Ventoy/video/index-tts/webui.py", line 51, in

from indextts.infer_v2 import IndexTTS2

File "/Volumes/Ventoy/video/index-tts/indextts/infer_v2.py", line 20, in

from indextts.gpt.model_v2 import UnifiedVoice

File "/Volumes/Ventoy/video/index-tts/indextts/gpt/model_v2.py", line 9, in

from indextts.gpt.transformers_gpt2 import GPT2PreTrainedModel, GPT2Model

File "/Volumes/Ventoy/video/index-tts/indextts/gpt/transformers_gpt2.py", line 34, in

from indextts.gpt.transformers_modeling_utils import PreTrainedModel

File "/Volumes/Ventoy/video/index-tts/indextts/gpt/transformers_modeling_utils.py", line 52, in

from transformers.loss.loss_utils import LOSS_MAPPING

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/loss/loss_utils.py", line 21, in

from .loss_d_fine import DFineForObjectDetectionLoss

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/loss/loss_d_fine.py", line 21, in

from .loss_for_object_detection import (

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/loss/loss_for_object_detection.py", line 32, in

from transformers.image_transforms import center_to_corners_format

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/image_transforms.py", line 21, in

from .image_utils import (

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/image_utils.py", line 59, in

from torchvision.transforms import InterpolationMode

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/torchvision/__init__.py", line 10, in

from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils  # usort:skip

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/torchvision/_meta_registrations.py", line 164, in

def meta_nms(dets, scores, iou_threshold):

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/torch/library.py", line 1069, in register

use_lib._register_fake(

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/torch/library.py", line 219, in _register_fake

handle = entry.fake_impl.register(

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/torch/_library/fake_impl.py", line 50, in register

if torch._C._dispatch_has_kernel_for_dispatch_key(self.qualname, "Meta"):

RuntimeError: operator torchvision::nms does not exist

4 Replies

这个错误与 pyVideoTrans 本身无关,而是您在尝试运行独立的 Index-TTS 语音克隆项目时,遇到了 PyTorch 和 torchvision 库版本不兼容的问题。

错误核心是 torchvision::nms 这个操作符不存在,通常是由于 torchtorchvision 版本不匹配,或者安装的 torchvision 版本过高/过低导致的。

解决方法:

  1. 确认环境: 您当前在 indextts 这个 Conda 环境中。请先激活它:

    conda activate indextts
  2. 卸载并重新安装匹配版本: 在激活的环境中,执行以下命令。请根据您的 CUDA 版本(或 CPU 版本)选择对应的安装命令。如果您不确定,可以先尝试 CPU 版本。

    • 对于 CUDA 11.8:

      pip uninstall torch torchvision torchaudio -y
      pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu118
    • 对于 CUDA 12.1:

      pip uninstall torch torchvision torchaudio -y
      pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cu121
    • 对于 CPU 版本:

      pip uninstall torch torchvision torchaudio -y
      pip install torch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cpu
  3. 重新启动项目: 安装完成后,再次尝试运行 Index-TTSwebui.py

如果问题依旧:
请检查 Index-TTS 项目的官方文档或 requirements.txt 文件,确认其明确要求的 torchtorchvision 版本,并严格按照要求安装。

请查看更多参考文档:

'(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /facebook/w2v-bert-2.0/resolve/main/preprocessor_config.json (Caused by ConnectTimeoutError(, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: fc489471-2aa1-4f0c-928f-0bb842b1d628)')' thrown while requesting HEAD https://huggingface.co/facebook/w2v-bert-2.0/resolve/main/preprocessor_config.json

Retrying in 8s [Retry 5/5].
'(MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /facebook/w2v-bert-2.0/resolve/main/preprocessor_config.json (Caused by ConnectTimeoutError(, 'Connection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: b9da9c62-a9d8-42ce-8ed6-e1421ec99afb)')' thrown while requesting HEAD https://huggingface.co/facebook/w2v-bert-2.0/resolve/main/preprocessor_config.json
Traceback (most recent call last):
File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/urllib3/connection.py", line 204, in _new_conn

sock = connection.create_connection(

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection

raise err

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/urllib3/util/connection.py", line 73, in create_connection

sock.connect(sa)

TimeoutErr
......
nection to huggingface.co timed out. (connect timeout=10)'))"), '(Request ID: b9da9c62-a9d8-42ce-8ed6-e1421ec99afb)')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/utils/hub.py", line 470, in cached_files

hf_hub_download(

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn

return fn(*args, **kwargs)

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1007, in hf_hub_download

return _hf_hub_download_to_cache_dir(

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1114, in _hf_hub_download_to_cache_dir

_raise_on_head_call_error(head_call_error, force_download, local_files_only)

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/huggingface_hub/file_download.py", line 1658, in _raise_on_head_call_error

raise LocalEntryNotFoundError(

huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Volumes/Ventoy/video/index-tts/webui.py", line 56, in

tts = IndexTTS2(model_dir=cmd_args.model_dir,

File "/Volumes/Ventoy/video/index-tts/indextts/infer_v2.py", line 115, in init

self.extract_features = SeamlessM4TFeatureExtractor.from_pretrained("facebook/w2v-bert-2.0")

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/feature_extraction_utils.py", line 384, in from_pretrained

feature_extractor_dict, kwargs = cls.get_feature_extractor_dict(pretrained_model_name_or_path, **kwargs)

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/feature_extraction_utils.py", line 510, in get_feature_extractor_dict

resolved_feature_extractor_file = cached_file(

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/utils/hub.py", line 312, in cached_file

file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs)

File "/Volumes/Ventoy/opt/miniconda3/envs/indextts/lib/python3.10/site-packages/transformers/utils/hub.py", line 543, in cached_files

raise OSError(

OSError: We couldn't connect to 'https://huggingface.co' to load the files, and couldn't find them in the cached files.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.

这个错误表明 Index-TTS 项目在启动时,需要从 HuggingFace 下载一个名为 facebook/w2v-bert-2.0 的模型文件,但由于网络连接问题(连接超时)而失败。这通常是由于中国大陆网络环境无法直接访问 HuggingFace 导致的。

核心解决方案:配置网络代理或使用离线模式。

请按以下步骤操作:

  1. 配置网络代理(推荐)

    • 如果您有可用的代理服务(如 Clash、V2Ray 等),请确保其已开启并正常工作。
    • 在运行 Index-TTS 的 命令行终端 中,激活 indextts 环境后,设置环境变量:

      # 对于 HTTP 代理
      export HTTP_PROXY="http://127.0.0.1:你的代理端口"
      export HTTPS_PROXY="http://127.0.0.1:你的代理端口"
      # 对于 SOCKS5 代理
      export HTTP_PROXY="socks5://127.0.0.1:你的代理端口"
      export HTTPS_PROXY="socks5://127.0.0.1:你的代理端口"
    • 设置完成后,再运行 python webui.py
  2. 手动下载模型文件(离线模式)

    • 如果无法使用代理,您需要手动下载模型文件并放置到正确位置。
    • 步骤 1:下载文件。访问错误信息中提到的 URL:https://huggingface.co/facebook/w2v-bert-2.0/resolve/main/preprocessor_config.json,以及其他可能需要的文件(如 pytorch_model.bin, config.json 等)。您可能需要通过能访问 HuggingFace 的网络环境或使用镜像站下载。
    • 步骤 2:找到缓存目录。在 Python 中运行以下代码可以找到 HuggingFace 的默认缓存路径:

      from transformers import TRANSFORMERS_CACHE
      print(TRANSFORMERS_CACHE)

      通常路径类似 ~/.cache/huggingface/hub

    • 步骤 3:放置文件。在缓存目录中,创建文件夹 models--facebook--w2v-bert-2.0,并将下载的所有文件放入其中的 snapshots/[一个哈希值]/ 目录下。最稳妥的方法是先让程序尝试下载一次(即使失败),它会创建好这个目录结构,您再将文件复制进去。
    • 步骤 4:以离线模式启动。在运行 webui.py 时,添加参数或设置环境变量 TRANSFORMERS_OFFLINE=1

      TRANSFORMERS_OFFLINE=1 python webui.py
  3. 使用国内镜像源(如果项目支持)

    • 有些项目支持通过环境变量 HF_ENDPOINT 指定镜像站。您可以尝试在运行前设置:

      export HF_ENDPOINT="https://hf-mirror.com"

      然后再次运行程序。注意:并非所有模型都在镜像站有完整备份,此方法可能不奏效。

对于 pyVideoTrans 用户:如果您是在 pyVideoTrans 中配置 Index-TTS 时遇到此问题,请确保在 pyVideoTrans 的 网络代理设置(主界面第5行)中填写了正确的代理地址,格式为 http://127.0.0.1:端口socks5://127.0.0.1:端口。pyVideoTrans 会将该代理设置传递给其调用的子进程(如 Index-TTS)。

请查看更多参考文档:

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.

Donate: https://ko-fi.com/jianchang512

Trending Questions