Skip to main content

Image Guided Editing Endpoint

Overview

V5 Picture to Picture endpoint is used to edit an image using a text prompt with the description of the desired changes.

Pass the image URL with the init_image parameter and add your description of the expected result to the prompt parameter.

Picture to picture endpoint result

Request

--request POST 'https://modelslab.com/api/v6/image_editing/pix2pix' \

Make a POST request to https://modelslab.com/api/v6/image_editing/pix2pix endpoint and pass the required parameters in the request body.

Watch the how-to video to see it in action.

Body Attributes

ParameterDescriptionValues
keyYour API Key used for request authorizationstring
promptText prompt with description of the things you want in the image to be generatedstring
init_imageLink to the initial imageURL
image_guidance_scaleThe scale for image guidance.min: 1, max: 8
stepsNumber of denoising steps. The minimum is 1 and the maximum is 50. The default is 20.integer
guidance_scaleScale for classifier-free guidance. The minimum is 1 and the maximum is 20.integer

Example

Body

Body
{
"key": "",
"init_image" : "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/2ILk0g1tgpk7wFFlc72hyAtdmHjxAj-metaZjNkNzVjMWQtMTI1OS00NDA4LTg0YmQtNzA0NTVmMTljZjcwLTAucG5n-.png",
"prompt" : "make him woman",
"image_guidance_scale" : 1,
"steps" : 50,
"guidance_scale" : 7
}

Request

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key": "",
"init_image" : "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/2ILk0g1tgpk7wFFlc72hyAtdmHjxAj-metaZjNkNzVjMWQtMTI1OS00NDA4LTg0YmQtNzA0NTVmMTljZjcwLTAucG5n-.png",
"prompt" : "make him woman",
"image_guidance_scale" : 1,
"steps" : 50,
"guidance_scale" : 7
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

fetch("https://modelslab.com/api/v6/image_editing/pix2pix", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response

Example Response
{
"status": "success",
"generationTime": 11.955173015594482,
"id": 235693,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/7f54383a-7c97-4d2f-885e-9761d57cc20b-0.png"
],
"proxy_links": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/7f54383a-7c97-4d2f-885e-9761d57cc20b-0.png",
"meta": {
"H": 512,
"W": 512,
"file_prefix": "7f54383a-7c97-4d2f-885e-9761d57cc20b",
"guidance_scale": 7.5,
"image_guidance_scale": 1,
"init_image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/livewire-tmp/2ILk0g1tgpk7wFFlc72hyAtdmHjxAj-metaZjNkNzVjMWQtMTI1OS00NDA4LTg0YmQtNzA0NTVmMTljZjcwLTAucG5n-.png",
"n_samples": 1,
"negative_prompt": "",
"outdir": "out",
"prompt": "make him woman",
"safetychecker": "no",
"seed": 2974742231,
"steps": 50
}
}