本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Stability.ai 稳定扩散 3.5 大号
Stable Diffusion 3.5 Large 模型采用 80 亿参数,支持 100 万像素分辨率的输出,适用于文本到图像和图像到图像生成任务。
请求正文在请求body字段中传递给InvokeModel。
模型调用请求正文字段
使用 Stable Diffusion 3.5 大型模型拨 InvokeModel 打电话时,请使用如下所示的 JSON 对象填充正文字段。
模型调用响应正文字段
当你使用 Stable Diffusion 3.5 Large 模型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
-
St Stability.ai able Diffusion 3.5 Large 模型具有以下用于文本到图像推理调用的推理参数。
可选参数
-
aspect_rat io(字符串)-控制生成图像的纵横比。仅对文本到图像请求有效。枚举:16:9、1:1、21:9、2:3、3:2、4:5、5:4、9:16、9:21。默认为 1:1。
-
模式(字符串)(GenerationMode)-默认:文本到图像。枚举:图像到图像或文本到图像。控制是文本到图像生成还是图像到图像生成,这将影响所需的参数:
-
种子(数字)-控制生成中随机性的值。范围:0 至 4294967294。默认值为 0(随机种子)。
| 最小值 |
最大值 |
默认 |
| 0 |
4294967294 |
0 |
-
negative_promp t(字符串)-描述要从输出图像中排除的元素的文本。最多 10,000 个字符
-
输出格式(字符串)-输出图像格式。枚举: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
-
St Stability.ai able Diffusion 3.5 Large 模型具有以下用于图像到图像推理调用的推理参数。
-
pro mpt(字符串)-所需输出图像的文本描述。最多 10,000 个字符
-
image(字符串)— Base64-encoded 输入图像。每边最少 64 像素。支持的格式:jpeg、png、webp。
-
模式(字符串)(GenerationMode)-默认:文本到图像。枚举:图像到图像或文本到图像。控制是文本到图像生成还是图像到图像生成,这将影响所需的参数:
-
强度(数字)-控制输入图像对输出的影响。范围:0 至 1。值为 0,则保留输入图像;值为 1,则忽略输入图像。
-
种子(数字)-控制生成中随机性的值。范围:0 至 4294967294。默认值为 0(随机种子)。
| 最小值 |
最大值 |
默认 |
| 0 |
4294967294 |
0 |
-
negative_promp t(字符串)-描述要从输出图像中排除的元素的文本。最多 10,000 个字符
-
输出格式(字符串)-输出图像格式。枚举: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
})
)