View a markdown version of this page

Stability.ai Stable Diffusion 3.5 Large - Amazon Bedrock

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Stability.ai Stable Diffusion 3.5 Large

Stable Diffusion 3.5 Large 模型使用 80 億個參數,並支援 100 萬像素解析度輸出,用於產生文字轉影像和影像轉影像。

請求內文在請求的 body 欄位傳遞到 InvokeModel

模型調用請求內文欄位

當您使用穩定擴散 3.5 大型模型進行 InvokeModel 呼叫時,請將如下所示的 JSON 物件填入本文欄位。

  • prompt – (字串) 所需輸出影像的文字描述。最多 10,000 個字元。

    下限 上限

    0

    10,000

模型調用回應內文欄位

當您使用穩定擴散 3.5 大型模型進行InvokeModel呼叫時,回應如下所示

{ 'seeds': [2130420379], "finish_reasons":[null], "images":["..."] }

完成原因不是 的回應null會如下所示:

{ "finish_reasons":["Filter reason: prompt"] }
  • seeds – (字串) 用於為模型產生影像的種子清單。

  • finish_reasons – 指出請求是否已經過篩選的列舉。null 將指出請求成功。目前可能的值:"Filter reason: prompt", "Filter reason: output image", "Filter reason: input image", "Inference error", null

  • images – 產生的影像清單,採用 base64 字串格式。

Text to image

Stability.ai Stable Diffusion 3.5 Large 模型具有下列推論參數,可用於文字轉影像推論呼叫。

  • prompt (字串) – 所需輸出影像的文字描述。最多 10,000 個字元。

    下限 上限
    0 10,000

選用參數

  • aspect_ratio (字串) – 控制所產生影像的長寬比。僅適用於文字轉影像請求。列舉:16:9、1:1、21:9、2:3、3:2、4:5、5:4、9:16、9:21。預設值為 1:1。

  • 模式 (字串) (GenerationMode) - 預設:text-to-image。列舉:image-to-image 或 text-to-image。控制是文字轉影像還是影像轉影像產生,這會影響需要哪些參數:

    • 文字轉影像只需要提示參數。

    • 影像轉影像需要提示、影像和強度參數。

  • seed (number) – 用於控制產生隨機性的值。範圍介於 0 至 4294967294 之間。預設值為 0 (隨機種子)。

    下限 上限 預設
    0 4294967294 0
  • negative_prompt (字串) – 說明要從輸出映像中排除之元素的文字。最多 10,000 個字元。

    下限 上限
    0 10,000
  • output_format (字串) – 輸出映像格式。列舉:jpeg、png、webp。預設值為 png。

import boto3 import json bedrock = boto3.client('bedrock-runtime', region_name='us-west-2') response = bedrock.invoke_model( modelId='stability.sd3-5-large-v1:0', body=json.dumps({ 'prompt': 'A car made out of vegetables.' }) )
Image to image

Stability.ai Stable Diffusion 3.5 Large 模型具有下列推論參數,可用於影像轉影像推論呼叫。

  • prompt (字串) – 所需輸出影像的文字描述。最多 10,000 個字元。

    下限 上限
    0 10,000
  • image (字串) – Base64-encoded輸入影像。每邊至少 64 像素。支援的格式:jpeg、png、webp。

  • 模式 (字串) (GenerationMode) - 預設:text-to-image。列舉:image-to-image 或 text-to-image。控制是文字轉影像還是影像轉影像產生,這會影響需要哪些參數:

    • 文字轉影像只需要提示參數。

    • 影像轉影像需要提示、影像和強度參數。

  • 強度 (數字) – 控制輸入影像對輸出的影響。範圍介於 0 至 1 之間。值 0 會保留輸入影像,值 1 會忽略輸入影像。

    下限 上限
    0 1
  • seed (number) – 用於控制產生隨機性的值。範圍介於 0 至 4294967294 之間。預設值為 0 (隨機種子)。

    下限 上限 預設
    0 4294967294 0
  • negative_prompt (字串) – 說明要從輸出映像中排除之元素的文字。最多 10,000 個字元。

    下限 上限
    0 10,000
  • output_format (字串) – 輸出映像格式。列舉:jpeg、png、webp。預設值為 png。

import boto3 import base64 import json # Load and encode image with open('input_image.jpg', 'rb') as image_file: image_base64 = base64.b64encode(image_file.read()).decode('utf-8') bedrock = boto3.client('bedrock-runtime', region_name='us-west-2') response = bedrock.invoke_model( modelId='stability.sd3-5-large-v1:0', body=json.dumps({ 'prompt': 'A car made out of vegetables.', 'image': image_base64, 'strength': 0.7 }) )