[PR #378] fix: Forge compatibility for get_token_counter (modules.sd_hijack rem… #367

Open
opened 2026-11-07 17:43:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Physton/sd-webui-prompt-all-in-one/pull/378
Author: @xiansk
Created: 5/4/2026
Status: 🔄 Open

Base: main ← Head: fix/forge-compatibility-token-counter


📝 Commits (1)

  • 4d73962 fix: Forge compatibility for get_token_counter (modules.sd_hijack removed)

📊 Changes

1 file changed (+92 additions, -37 deletions)

View changed files

📝 scripts/physton_prompt/get_token_counter.py (+92 -37)

📄 Description

…oved)

问题

Forge 移除了 modules.sd_hijack 模块,导致插件在 Forge 下启动报错:
ModuleNotFoundError: No module named 'modules.sd_hijack'

修复方案

  • model_hijack 改为 try/except 导入,不存在时不崩溃
  • Forge 路径下新增 _get_prompt_lengths_forge() 平替实现,三层 fallback:
    1. cond_stage_model.tokenize_line()
    2. cond_stage_model.tokenize()
    3. transformers.CLIPTokenizer(兜底)
  • A1111 原版路径完全不变,向下兼容

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Physton/sd-webui-prompt-all-in-one/pull/378 **Author:** [@xiansk](https://github.com/xiansk) **Created:** 5/4/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/forge-compatibility-token-counter` --- ### 📝 Commits (1) - [`4d73962`](https://github.com/Physton/sd-webui-prompt-all-in-one/commit/4d7396210a7b03281e01986ff694e9d5f472e7d1) fix: Forge compatibility for get_token_counter (modules.sd_hijack removed) ### 📊 Changes **1 file changed** (+92 additions, -37 deletions) <details> <summary>View changed files</summary> 📝 `scripts/physton_prompt/get_token_counter.py` (+92 -37) </details> ### 📄 Description …oved) ## 问题 Forge 移除了 `modules.sd_hijack` 模块,导致插件在 Forge 下启动报错: `ModuleNotFoundError: No module named 'modules.sd_hijack'` ## 修复方案 - `model_hijack` 改为 try/except 导入,不存在时不崩溃 - Forge 路径下新增 `_get_prompt_lengths_forge()` 平替实现,三层 fallback: 1. `cond_stage_model.tokenize_line()` 2. `cond_stage_model.tokenize()` 3. `transformers.CLIPTokenizer`(兜底) - A1111 原版路径完全不变,向下兼容 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Physton/sd-webui-prompt-all-in-one#367
No description provided.