Generate Backgrounds
Action
GenerateBackgrounds
Introduction
This interface is used to generate backgrounds for a transparent image.
Request
Parameter Name | Type | Description | Required |
---|---|---|---|
Action | String | The corresponding API instruction name | ✓ |
PublicKey | String | User's public key, which can be obtained from the PICPIK User Center (opens in a new tab) | ✓ |
Signature | String | User's signature generated based on the public key and API instruction, see Signature for details | ✓ |
request_uuid | String | Request UUID, randomly generated by using the UUID generation method. This parameter can be utilized to manage the requests of your business and clients. |
Parameter Name | Type | Description | Required |
---|---|---|---|
MainModel | Model | Main model for generating images | ✓ |
SubModelList | []Model | The submodel list for generating images includes LoRA, Embedding, and HyperNetwork. | |
PositivePrompts | []String | Content description of what you want to appear in the image. | |
NegativePrompts | []String | Content description of what you do not want to appear in the image. | |
TranslatePrompts | Bool | Translate other languages to English, see support language list here. Default value: true | |
Seed | Int | The number of a seed (-1~2147483647), -1 represents a ramdom seed. Default value: -1 | |
Width | Int | Image width (64~2560). Default value: 1024 | |
Height | Int | Image height (64~2560). Default value: 1024 | |
BatchSize | Int | Batch size for generating images (1~16). Default value: 1 | |
UseMainModelVAE | Bool | Whether to use the codec that comes with the main model. Default value: false |
Parameter Name | Type | Description | Required |
---|---|---|---|
BackgroundImage2Image | Image2Image | Parameters related to an extra backgound reference image when generating. | |
TransparentForeground | Foreground | Parameters related to the foreground image. Note: A PNG image with alpha channel is required. | ✓ |
ImageList | []Base64 | A list of reference images encoded in Base64. | ✓ |
Intro to Complex Data Types
Model
Field Name | Type | Description | Required |
---|---|---|---|
Name | String | Model name | |
ModelCode | String | Model code | ✓ |
IsOfficial | Bool | Is official model or not | |
TriggerWordList | []String | Trigger word list, only available with LoRA model | |
InferenceParams | InferenceParams | Inference parameters |
Image2Image
Parameter Name | Type | Description | Required |
---|---|---|---|
ImageIndex | Int | The index of an image in ImageAndMaskList or ImageList , starting from 0. | ✓ |
ReferStrength | Float | The reference strength of this image (0~1). Default value: 0.5 |
Foreground
Parameter Name | Type | Supported Interface | Description | Required |
---|---|---|---|---|
ImageIndex | Int | General | The index of a foreground image in ImageAndMaskList or ImageList , starting from 0. | ✓ |
ResizeMode | String | General | Specifying the resize mode of the foreground image when the final generating dimension is different. Reference values: JustResize, CropAndResize, ResizeAndFill. Default value: ResizeAndFill | |
ClothesMaskIndex | Int | GenerateFromMannequin | Specifying the clothes to be kept on the mannequin. The index of the mask image in ImageAndMaskList or MaskList starts from 0. The mask is a black-and-white image where the white part represents the redrawn area. You can draw masks independently or obtain them through the "Remove Background" or "Content Extraction" APIs. | ✓ |
InvertMask | Bool | GenerateFromMannequin | Invert the mask, default value: false |
InferenceParams
Note: Specific parameters are only valid for a particular model data type (parent) and are not generic.
Parameter Name | Type | Valid Parent Type | Description | Default | Range | Step | Required |
---|---|---|---|---|---|---|---|
LoraWeight | Float | Model | The influence weight when inferencing. Only available with the LoRA model. | 1 | -1~2 | 0.01 | |
Resolution | Int | PreProcessor | The resolution of images generated by the pre-processor. | 512 | 64~2048 | 64 | |
ControlWeight | Float | ControlModel | The influence weight of a ControlNet model when inferencing. | 1 | 0~2 | 0.01 | |
StartingStep | Float | ControlModel | Timing (ratio) of a ControlNet model to start intervening in the inference process. | 0 | 0~1 | 0.01 | |
EndingStep | Float | ControlModel | Timing (ratio) of a ControlNet model to stop intervening in the inference process. | 1 | 0~1 | 0.01 |
Request Example
{
"Action": "GenerateBackgrounds",
"PublicKey": "ALLak9M4cNdHXKOJAJJ4k8Hh1hZS2EgJF1D0FlPwfl",
"Signature": "a44f6dc64600d7580211c50e4e8e2ebfe07123c6",
"request_uuid": "5ae03609-451b-44d7-a351-c72904df881b",
"MainModel": {
"InferenceParams": {
"Steps": 10
},
"ModelCode": "PICPIK General"
},
"BackgroundImage2Image": {
"ImageIndex": 1,
"ReferStrength": 0.3,
"ResizeMode": "ResizeAndFill",
},
"NegativePrompts": [],
"PositivePrompts": ["blue sky","white cloud"],
"TranslatePrompts": false,
"TransparentImageIndexList": [0],
"ImageList": [
"data:image/jpeg;base64,img1",
"data:image/jpeg;base64,img2"
]
}
Response
Field Name | Type | Description | Required |
---|---|---|---|
RetCode | Int | Return status code: 0 indicates a successful return, while non-zero indicates a failure | ✓ |
Action | String | Instruction name | ✓ |
Message | String | The error message is returned when RetCode is non-zero, providing a detailed description | |
request_uuid | String | Returns the UUID that was included in the request |
Parameter Name | Type | Description | Required |
---|---|---|---|
TaskUID | String | Task UID List, used to query task details and get results | ✓ |
Response Example
{
"Action": "GenerateBackgrounds",
"RetCode": 0,
"Message": "",
"request_uuid": "5ae03609-451b-44d7-a351-c72904df881b",
"TaskUID": "ckt3uqacrh4miq8mr9lgg"
}