img2img

Function

Interacts with foundation model services to generate images and obtains the model inference result. The format of the data sent to a foundation model is as follows:

The request body data format is as follows:
{
"prompt": prompt for generating an image,
"image": Base64-encoded image data,
"size": image size,
"model_name": model name
}

Prototype

def img2img(prompt, image_content, size)

Parameters

Parameter

Data Type

Required/Optional

Description

prompt

str

Required

Prompt for generating an image. The length range is [1, 1024 × 1024].

image_content

str

Required

Character string corresponding to the Base64 encoded image data. The length range is (0, 10 × 1024 × 1024].

size

str

Optional

Image size, in the format of "height × width". The supported size depends on the corresponding foundation model. The value needs to meet the regular expression requirement "^\d{1,5}\*\d{1,5}$". The default value is 512 × 512.

Return Value

Data Type

Description

dict

The return format is {"prompt": prompt, "result": data}, where prompt indicates the prompt for generating an image, and result indicates the Base64-encoded image data of the foundation model inference result.