Skip to main content

Outpainting

With outpainting, you can extend the borfder of the image in any directions. The AI examines the colors, shapes, and overall style of the image. Then, it starts generating new pixels in the direction you choose (up, down, left, right).

Tip
  • Leave the prompt blank to let the AI automatically design the extended areas
  • The strength, overlap, stretch_area, stretch_scale, horizontal_tile, vertical_tile params have been optimized for you and doesn't need to be changed but offers fine-tuning to those who need it.

import requests
import json
url = "https://api.imagepipeline.io/outpainting/v1"
headers = {
"API-Key": "Your API Key"
}
data = {
"init_image": "https://f005.backblazeb2.com/b2api/v2/b2_download_file_by_id?fileId=4_zfdf0a8ed59e8666b89b10713_f1009f7bd8006edff_d20240216_m085518_c005_v0501017_t0017_u01708073718621",
"prompt": "",
"direction": ["right", "left", "down", "up"],
"expansion": [64, 64, 64, 64],
"num_inference_steps": 30,
"guidance_scale": 7.5,
"resolution": 1024,
"samples": 2,
"strength": 0.7,
"overlap": 0.02,
"stretch_area": 0.3,
"stretch_scale": 2,
"horizontal_tile": 3,
"vertical_tile": 24,
"server_id": ""
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

JSON Parameters

ParameterPermissible valuesNotes
init_imagestrPublic URL for init image
num_inference_stepsint, [0-51]Number of inference steps. Noise is reduced with each step, improving image quality. Recommended: 30-50
strengthfloat, [0-1]Strength of controlnet. Higher values prioritize preserving input features. Recommended: 0.5-1.0
guidance_scalefloat, [0, 20]Scale for guidance. Higher values prioritize relevance to text prompts over image quality. Recommended: 7.5-12.5
directionstr, arrayArray of directions for expansion: left, right, up, down
samplesint, [0-2]Number of samples to generate. Maximum 2 per API call. Recommended: 2
expansionint, arrayArray of height/width to extend by. Needs to be a multiple of 8
overlapfloat, [0, 0.05]Smoothening of outpainted edges. Recommended: 0.01
horizontal_tileintNumber of horizontal tiles when expanding horizontally. Recommended: 3
vertical_tileintNumber of vertical tiles when expanding vertically. Recommended: 24
stretch_areanumberArea to stretch
stretch_scaleintegerScale for stretching
resolutionint, [0-1024]Resolution for outpainted image. Recommended: 1024
server_idstringServer_id for enterprise subscription. Provide any for load-balancing, specific id for routing
webhookstringWebhook to send generated image to

Status

Your response will include a status.

  • If the status = SUCCESS, you will also have download_urls that will have the links to your generated image based on the number of samples you have entered. The maximum number of samples that can be generated is 2.
  • If the status = PENDING, you will receive a id. You can use the status endpoint to fetch your image using the id.
  • If the status = FAILURE, you will receive only an error message.

Endpoint: [GET]

  • https://api.imagepipeline.io/outpainting/v1/status/{{id}}

Pass the API-Key as the authorization in the header.

{
"init_image": "https://f005.backblazeb2.com/b2api/v2/b2_download_file_by_id?fileId=4_zfdf0a8ed59e8666b89b10713_f1009f7bd8006edff_d20240216_m085518_c005_v0501017_t0017_u01708073718621",
"prompt": "",
"direction": ["right", "left", "down", "up"],
"expansion": [64, 64, 64, 64],
"num_inference_steps": 30,
"guidance_scale": 7.5,
"resolution": 1024,
"samples": 2,
"strength": 0.7,
"overlap": 0.02,
"stretch_area": 0.3,
"stretch_scale": 2,
"horizontal_tile": 3,
"vertical_tile": 24
}