You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Google Colab运行Forge Neo时遇Gradio数值越界错误求助

解决Forge Neo在Colab运行ZIT时的Gradio滑块值错误

问题背景

在Google Colab中通过以下命令安装Forge Neo以运行ZIT:

!pip install -U protobuf

!pip uninstall -y tensorflow tensorflow-cpu tensorflow-gpu tf-keras  
!pip install -U "protobuf>=5.28.0"

!pip install gradio-rangeslider

%cd /content/sd-webui-forge-neo  
!python launch.py --share

启动后无法生成图片,抛出如下错误:

Traceback (most recent call last):  
File "/usr/local/lib/python3.12/dist-packages/gradio/routes.py", line 1298, in predict  
output = await route_utils.call_process_api(  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File "/usr/local/lib/python3.12/dist-packages/gradio/route_utils.py", line 354, in call_process_api  
output = await app.get_blocks().process_api(  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 2187, in process_api  
inputs = await self.preprocess_data(  
^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File "/usr/local/lib/python3.12/dist-packages/gradio/blocks.py", line 1849, in preprocess_data  
processed_input.append(block.preprocess(inputs_cached))  
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  
File "/usr/local/lib/python3.12/dist-packages/gradio/components/slider.py", line 163, in preprocess  
Number.raise_if_out_of_bounds(payload, self.minimum, self.maximum)  
File "/usr/local/lib/python3.12/dist-packages/gradio/components/number.py", line 129, in raise_if_out_of_bounds  
raise Error(f"Value {num} is less than minimum value {minimum}.")  
gradio.exceptions.Error: 'Value -1 is less than minimum value 64.'

已知问题出在ControlNet的Resize/Processor Resolution参数被设为-1,但因错误无法进入界面修改。

解决方案

1. 直接修改ControlNet配置文件

通过命令行修改ControlNet的配置,将违规的-1值替换为合法数值(如512):

# 进入ControlNet扩展目录
%cd /content/sd-webui-forge-neo/extensions/sd-webui-controlnet
# 替换resize_resolution字段值
!sed -i 's/"resize_resolution": -1/"resize_resolution": 512/g' config.json
# 若存在processor_resolution字段也一并替换
!sed -i 's/"processor_resolution": -1/"processor_resolution": 512/g' config.json

修改完成后重启WebUI即可。

2. 回退Gradio到兼容版本

高版本Gradio可能对滑块组件的数值限制逻辑做了调整,回退到稳定兼容版本:

# 卸载现有Gradio及相关组件
!pip uninstall -y gradio gradio-rangeslider
# 安装指定兼容版本
!pip install gradio==3.41.0 gradio-rangeslider==0.2.0
# 重启WebUI
%cd /content/sd-webui-forge-neo
!python launch.py --share

3. 清除WebUI缓存配置

删除WebUI主配置中ControlNet的相关缓存项,让系统重新生成默认配置:

# 安装jq工具用于JSON操作
!apt-get install -y jq
# 进入WebUI目录
%cd /content/sd-webui-forge-neo
# 删除config.json中的controlnet节点
!jq 'del(.controlnet)' config.json > temp_config.json && mv temp_config.json config.json
# 重启WebUI
!python launch.py --share

4. 启动时强制指定参数(可选)

部分WebUI支持通过启动参数直接设置ControlNet的分辨率,尝试添加如下参数启动:

%cd /content/sd-webui-forge-neo
!python launch.py --share --controlnet-resize-resolution 512

内容的提问来源于stack exchange,提问作者長々白鷺

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 22:04:52