Mac M1 ComfyUI 中 AnyText插件安装问题汇总?

Q1:NameError: name 'PreTrainedTokenizer' is not defined ?

该项目最近更新日期为2024年12月,该时间段的transformers 版本由PyPI 上的 transformers 页面可知为4.47.1.

A1: transformers 版本不满足要求,必须降级transformors ?

(1)查看 transformers 版本
bash 复制代码
pip index versions transformers 

发现是最新版4.48.2,降级到4.46.2

bash 复制代码
pip install transformers==4.46.2

Q2:"ComfyUI/custom_nodes/ComfyUI_Anytext/Image_Generation_AnyText/Site_Packages/AnyTextControlDiffusion/ldm/modules/encoders/modules.py" AssertionError: Torch not compiled with CUDA enabled". ?

A2: 将modules.py文件里下面这行代码:

bash 复制代码
tokens = tokens.to(self.device)

修改为如下内容:

bash 复制代码
self.device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")
tokens = tokens.to(self.device)

Q3:'ComfyUI_Anytext/Image_Generation_AnyText/Site_Packages/AnyTextControlDiffusion/cldm/ddim_hacked.py' AssertionError: Torch not compiled with CUDA enabled?

A3:

在 ddim_hacked.py 文件中,将 register_buffer 方法里这行代码
bash 复制代码
attr = attr.to(torch.device("cuda"))

修改为

bash 复制代码
if torch.backends.mps.is_available():
  attr = attr.to(torch.device("mps"))
else:
  attr = attr.to(torch.device("cpu"))

Q4: ComfyUI/custom_nodes/ComfyUI_Anytext/Image_Generation_AnyText/Site_Packages/AnyTextControlDiffusion/cldm/ddim_hacked.py", line 22, in register_buffer attr = attr.to(torch.device("mps")) TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead?

A4:

在 ddim_hacked.py 文件中,将 register_buffer 方法里这行代码
bash 复制代码
if torch.backends.mps.is_available():
  attr = attr.to(torch.device("mps"))
else:
  attr = attr.to(torch.device("cpu"))

修改为:

bash 复制代码
if attr.dtype == torch.float64:
  attr = attr.to(torch.float32)
if torch.backends.mps.is_available():
  attr = attr.to(torch.device("mps"))
else:
  attr = attr.to(torch.device("cpu"))
相关推荐
得贤招聘官14 小时前
精准招聘新纪元:AI 重构选才逻辑
人工智能
ChatPPT_YOO15 小时前
智能演示时代:8款免费AI PPT生成工具全面评测
人工智能·powerpoint·ai生成ppt·ppt制作
却道天凉_好个秋15 小时前
OpenCV(二十一):图像的放大与缩小
人工智能·opencv·计算机视觉
风暴之零15 小时前
卡尔曼滤波学习
人工智能·学习·机器学习
DatGuy16 小时前
Week 24: 深度学习补遗:Vision Transformer (ViT) 复现
人工智能·深度学习·transformer
A尘埃16 小时前
项目三:信息抽取与图谱问答(医疗科研文献知识图谱与智能问答平台)
人工智能·windows·知识图谱
鹿鸣悠悠16 小时前
AI测试(含大模型)与普通测试的区别及实施方法
人工智能
闲看云起17 小时前
一文了解RoPE(旋转位置编码)
人工智能·语言模型·自然语言处理
whaosoft-14317 小时前
51c视觉~合集50
人工智能
金紫火17 小时前
美团CatPaw:一款AI驱动的编程工具解析
人工智能