ControlNet tools
Introduction
ControlNet offers advanced capabilities for precise image processing through the use of guide images in specific formats, known as preprocessed images. This powerful tool enhances the control and customization of image generation, enabling users to achieve desired artistic styles and detailed adjustments effectively.
Using ControlNet via our API simplifies the integration of guide images into your workflow. By leveraging the API, you can seamlessly incorporate preprocessed images and specify various parameters to tailor the image generation process to your exact requirements.
Request
Our API always accepts an array of objects as input, where each object represents a specific task to be performed. The structure of the object varies depending on the type of the task. For this section, we will focus on the parameters related to the ControlNet preprocessing task.
The following JSON snippet shows the basic structure of a request object. All properties are explained in detail in the next section.
taskType
The type of task to be performed. For this task, the value should be
imageControlNetPreProcess
.taskUUID
When a task is sent to the API you must include a random UUID v4 string using the
taskUUID
parameter. This string is used to match the async responses to their corresponding tasks.If you send multiple tasks at the same time, the
taskUUID
will help you match the responses to the correct tasks.The
taskUUID
must be unique for each task you send to the API.outputType
Specifies the output type in which the image is returned. Supported values are:
dataURI
,URL
, andbase64Data
.base64Data
: The image is returned as a base64-encoded string using theguideImageBase64Data
parameter in the response object.dataURI
: The image is returned as a data URI string using theguideImageDataURI
parameter in the response object.URL
: The image is returned as a URL string using theguideImageURL
parameter in the response object.
outputFormat
Specifies the format of the output image. Supported formats are:
PNG
,JPG
andWEBP
.includeCost
If set to
true
, the cost to perform the task will be included in the response object.inputImage
Specifies the input image to be preprocessed to generate a guide image. This guide image will be used as a reference for image generation processes, guiding the AI to generate images that are more aligned with the input image. The input image can be specified in one of the following formats:
- An UUID v4 string of a previously uploaded image or a generated image.
- A data URI string representing the image. The data URI must be in the format
data:<mediaType>;base64,
followed by the base64-encoded image. For example:data:image/png;base64,iVBORw0KGgo...
. - A base64 encoded image without the data URI prefix. For example:
iVBORw0KGgo...
. - A URL pointing to the image. The image must be accessible publicly.
Supported formats are: PNG, JPG and WEBP.
preProcessorType
The preprocessor to be used. Possible values:
height
If the
inputImage
height dimension is larger than this value, the output image will be resized to the specified height in this parameter.If the parameter
width
is not set, the output image will maintain the aspect ratio.width
If the
inputImage
width dimension is larger than this value, the output image will be resized to the specified width in this parameter.If the parameter
height
is not set, the output image will maintain the aspect ratio.lowThresholdCanny
Defines the lower threshold when using the Canny edge detection preprocessor.
The recommended value is
100
.highThresholdCanny
Defines the high threshold when using the Canny edge detection preprocessor.
The recommended value is
200
.includeHandsAndFaceOpenPose
Include the hands and face in the pose outline when using the OpenPose preprocessor.
Response
Results will be delivered in the format below.
taskUUID
The API will return the
taskUUID
you sent in the request. This way you can match the responses to the correct request tasks.inputImageUUID
The unique identifier of the original image used as input for the preprocessing task.
guideImageUUID
The unique identifier of the preprocessed image.
guideImageURL
If
outputType
is set toURL
, this parameter contains the URL of the preprocessed image to be downloaded.guideImageBase64Data
If
outputType
is set tobase64Data
, this parameter contains the base64-encoded data of the preprocessed image.guideImageDataURI
If
outputType
is set todataURI
, this parameter contains the data URI of the preprocessed image.cost
if
includeCost
is set totrue
, the response will include acost
field for each task object. This field indicates the cost of the request in USD.