Missing `config.json` file

用户在更新 Fooocus 项目后,启动 WebUI 时出现该错误。报错栈指向 `modules/expansion.py` 中的 `AutoTokenizer.from_pretrained()` 调用,该函数尝试加载 `prompt_expansion/fooocus_expansion` 路径

Missing `config.json` file

Missing `config.json` file

快速结论:此报错通常出现在更新 Fooocus 或首次启动后,提示模型目录下缺少 `config.json` 文件。优先排查 `Fooocus/models/prompt_expansion/fooocus_expansion/` 目录中是否完整包含 `pytorch_model.bin` 和 `config.json` 两个文件,常见原因是模型文件未随 Git 更新正确同步。

问题场景

用户在更新 Fooocus 项目后,启动 WebUI 时出现该错误。报错栈指向 `modules/expansion.py` 中的 `AutoTokenizer.from_pretrained()` 调用,该函数尝试加载 `prompt_expansion/fooocus_expansion` 路径下的预训练 tokenizer,但缺少 `config.json` 文件。用户目录 `models/prompt_expansion/fooocus_expansion/` 中仅包含 `pytorch_model.bin`,缺少 `config.json`。

报错原文

OSError: \Path\to\Fooocus_win64_1-1-1035_4\Fooocus\models\prompt_expansion\fooocus_expansion does not appear to have a file named config.json. Checkout 'https://huggingface.co/\Path\to\Fooocus_win64_1-1-1035_4\Fooocus\models\prompt_expansion\fooocus_expansion/None' for available files.

原因分析

可能原因:Fooocus 的 prompt expansion 模型目录需要一个完整的 Hugging Face tokenizer 目录,包含 `pytorch_model.bin` 和 `config.json` 等多个文件。项目更新后,`prompt_expansion/fooocus_expansion` 目录未通过 Git 拉取或下载完整,导致启动时无法加载。用户使用软链接(symlink)连接模型目录(如从 ComfyUI 安装链接),或通过 Pinokio、便携版(win64 1-1-1035_4)等非标准方式部署时更易触发。

环境排查

  • 确认 Fooocus 版本(例如 win64_1-1-1035_4 或 Git 仓库的最新 commit)。
  • 检查模型目录:`Fooocus/models/prompt_expansion/fooocus_expansion/`
  • 列出该目录下所有文件:应包含 `config.json`、`pytorch_model.bin` 等文件(完整模型文件列表可参考 GitHub 仓库对应目录)。
  • 如果使用软链接或符号链接,检查链接路径是否完整并且可读。
  • 确认 Git 仓库是否完整拉取(尤其是 `models/prompt_expansion/` 子目录)。

解决步骤

  1. 在 Fooocus 项目根目录下运行以下命令恢复 prompt expansion 模型目录:
    git restore models/prompt_expansion/
    注:如果使用便携版(非 Git 仓库),此命令可能无效,请检查是否有 `models/prompt_expansion/` 目录的 Git 历史。
  2. 如果步骤 1 失败,确认 `Fooocus/models/prompt_expansion/fooocus_expansion/` 目录是否完整。如果仅包含 `pytorch_model.bin`,缺少 `config.json`,则:
    • 从 GitHub 仓库的对应目录手动下载缺失的 `config.json` 文件,放入该目录。
    • 或者删除整个 `fooocus_expansion` 目录,重新运行 Fooocus(启动时自动下载完整模型)。
  3. 如果使用软链接/符号链接:断开链接,将模型目录恢复为本地物理目录,然后重新同步文件。
  4. 作为临时工作区,可尝试使用 Colab Notebook 运行 Fooocus(如 Docker 镜像方式),参见 Colab 本地运行时说明

验证方法

检查 `Fooocus/models/prompt_expansion/fooocus_expansion/` 目录下是否存在 `config.json` 文件。然后重新启动 Fooocus WebUI,观察启动日志中是否仍出现 `OSError` 报错。如果正常启动且无报错,则问题解决。

参考来源

lllyasviel/Fooocus #341

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 7843

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注