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

使用Colab、Google Cloud与Python生图时seed参数报错求助

Google Vertex AI图像生成添加seed参数报错求助

环境配置代码

!pip install --quiet --upgrade --user google-cloud-aiplatform
import IPython
import time

app = IPython.Application.instance()
app.kernel.do_shutdown(True)
from google.colab import auth
auth.authenticate_user()

import vertexai
vertexai.init(project="$PROJECT_ID", location = "us-central1")
from vertexai.preview.vision_models import ImageGenerationModel
model = ImageGenerationModel.from_pretrained("imagegeneration@005")
!pip install --upgrade watermark

可正常运行的图像生成代码

response = model.generate_images(
prompt = '''A flower.''',
number_of_images = 2
)

问题场景

添加seed参数后执行代码时报错:

model.watermark_enabled = False
response = model.generate_images(
prompt = '''A flower.''',
number_of_images = 2,
seed = 42
)

错误信息

_InactiveRpcError                         Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     71         try:
---> 72             return callable_(*args, **kwargs)
     73         except grpc.RpcError as exc:

8 frames
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "Image generation failed with the following error: Seed is not supported when watermark is enabled."
    debug_error_string = "UNKNOWN:Error received from peer ipv4:142.250.141.95:443 {created_time:"2024-05-23T14:53:50.497705026+00:00", grpc_status:3, grpc_message:"Image generation failed with the following error: Seed is not supported when watermark is enabled."}"
>

The above exception was the direct cause of the following exception:

InvalidArgument                           Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     72             return callable_(*args, **kwargs)
     73         except grpc.RpcError as exc:
---> 74             raise exceptions.from_grpc_error(exc) from exc
     75 
     76     return error_remapped_callable

InvalidArgument: 400 Image generation failed with the following error: Seed is not supported when watermark is enabled.

已尝试的操作

  • 添加model.watermark_enabled = False后重新执行,无效
  • 尝试设置model.watermark_enabled = True,仍失败
  • 执行!pip install --upgrade watermark后重复上述两种设置,问题依旧

寻求解决方法。

内容的提问来源于stack exchange,提问作者Andrew

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 13:38:18