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"))
相关推荐
居然JuRan5 小时前
一张日落照片,为什么传统数据库"看不懂"?揭秘向量数据库的魔力
人工智能
美团技术团队5 小时前
LongCat 上线 AI 生图!精准高效,AI 创作不设限
人工智能
xixixi777775 小时前
NTN(神经张量网络):让AI学会“关系推理”的里程碑
网络·人工智能·神经网络·ai·大模型·ntn
测试人社区—84165 小时前
Mocking与Stubbing在单元测试中的正确使用
人工智能·git·单元测试·自动化·bug·postman
产业家5 小时前
宝马,如何建设一座AI汽车工厂?|产业AI案例
人工智能·汽车
后端小肥肠5 小时前
小红书儿童绘本这样做!Coze+Nano Banana Pro批量生产挂橱窗
人工智能·aigc·coze
nwsuaf_huasir6 小时前
深度学习2-PyTorch基础-张量
人工智能·pytorch·深度学习
得贤招聘官6 小时前
AI 面试智能体:破解招聘瓶颈的智能化解决方案
人工智能
轻竹办公PPT6 小时前
AI自动写年终总结PPT
人工智能·python·powerpoint
ARM+FPGA+AI工业主板定制专家6 小时前
基于JETSON/RK3588+FPGA+AI农业机器人视觉感知方案
人工智能·计算机视觉·fpga开发·机器人