Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

401 Deadline exception when using Imagen Python

未关闭
#12,020 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
google-cloud, python
领域
ai, cloud

调研方向

从提供的 Imagen Python 代码片段和显示 401 Deadline 失败的 Cloud Run 错误日志开始。检查是否可以在 model.generate_images 附近复现该失败,并确定相关的 Vertex AI 请求行为;当原因和经过验证的解决方案都记录完毕后,该 issue 即完成。

由索引模型根据 Issue 内容生成。

描述

priority: p2 samples triage me type: bug

Example code:

vertexai.init(project=PROJECT_ID, location=LOCATION)
model: ImageGenerationModel = ImageGenerationModel.from_pretrained(model_name=MODEL_NAME)

Common.log_info(message='Handling image generation request')
Common.log_https_request(req=req)
data: dict = req.data
prompt: str = data.get(PROMPT_KEY, '')
user_id: str = req.auth.uid
if not user_id:
    Common.log_info(message='Invalid user id, not generating image')
    return
if not prompt:
    Common.log_info(message='Invalid prompt, not generating image')
    return
number_of_images: int = data.get(NUMBER_OF_IMAGES_KEY, 1)
guidance_scale: int = data.get(GUIDANCE_SCALE_KEY, MEDIUM_GUIDANCE_SCALE)
output_image_path: str = (GENERATED_IMAGE_PREFIX + user_id +
                          '/' +
                          Common.get_current_datetime() + '/' +
                          Common.replace_all_whitespace_with_underscore(
                              input_string=prompt) + JPEG_SUFFIX)
output_gcs_uri: str = BUCKET_URI_PREFIX + output_image_path
Common.log_info(message=f'Generating image at: {output_gcs_uri}')
model.generate_images(
    prompt=prompt,
    number_of_images=number_of_images,
    aspect_ratio=Common.convert_to_aspect_ratio(input_string=data.get(ASPECT_RATIO_KEY, '')),
    output_gcs_uri=BUCKET_URI_PREFIX + output_image_path,
    language=AUTO_LANGUAGE_DETECTION,
    guidance_scale=guidance_scale,
    add_watermark=False,
    safety_filter_level=STRICT_SAFETY_FILTER,
    person_generation=ALLOW_ADULT_PERSON_GENERATION,
)
Common.log_info(message=f'Generated image at: {output_image_path}')
return {
    GENERATED_IMAGE_PATH_KEY: output_image_path
}

Log output

{
insertId: "668e115800009112eb018410"
labels: {
execution_id: "RCyLEQaZkqtT"
goog-managed-by: "cloudfunctions"
instanceId: "0087244a805cf6d58e414f53f12334887c32a9193fd30e864537965aed11aef51420d9a28124761e498af43bce228ec8099599bc142b0e59e58e9ea6dac43d80"
}
logName: "projects/claptrap-project/logs/run.googleapis.com%2Fstderr"
receiveTimestamp: "2024-07-10T04:43:04.043022212Z"
resource: {
labels: {
configuration_name: "generate-images"
location: "us-central1"
project_id: "claptrap-project"
revision_name: "generate-images-00004-mil"
service_name: "generate-images"
}
type: "cloud_run_revision"
}
severity: "ERROR"
spanId: "10602671325904409459"
textPayload: "An exception occurred: 401 Image generation failed with the following error: Deadline"
timestamp: "2024-07-10T04:43:04.037138Z"
}

主要语言
Jupyter Notebook
星标
8.1k
派生
6.7k
平均合并
4 天 4 小时
30 天内合并 PR
8

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

GoogleCloudPlatform/python-docs-samples 的其他 Issue

查看 GoogleCloudPlatform/python-docs-samples 的全部 Issue

相似的 Issue

更多 AI Infra & Agents Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。