本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
Stability.ai Stable Diffusion 3.5 Large
Stable Diffusion 3.5 Large 型号使用 80 亿个参数,并支持 100 万像素分辨率的输出 text-to-image和 image-to-image生成。
请求正文在请求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
-
Stability.ai Stable Diffusion 3.5 大型模型具有以下用于推理调用的 text-to-image推理参数。
可选参数
-
aspect_rat io(字符串)-控制生成图像的纵横比。仅对 text-to-image请求有效。枚举: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控制这是 text-to-image还是层 image-to-image代,这会影响需要哪些参数:
-
种子(数字)-控制生成中随机性的值。范围: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
-
Stability.ai Stable Diffusion 3.5 大型模型具有以下用于推理调用的 image-to-image推理参数。
-
pro mpt(字符串)-所需输出图像的文本描述。最多 10,000 个字符
-
图片(字符串)— Base64 编码的输入图像。每边最少 64 像素。支持的格式:jpeg、png、webp。
-
模式(字符串)(GenerationMode)-默认: text-to-image。枚举: image-to-image或。 text-to-image控制这是 text-to-image还是层 image-to-image代,这会影响需要哪些参数:
-
强度(数字)-控制输入图像对输出的影响。范围: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
})
)