Skip to main content

Inf Edit Endpoint

Overview

This endpoint allows for consistent editing at both the semantic and spatial levels, catering to intricate modifications without compromising on the image's integrity.

caution

Image url generated will not be accessible after 24 hours, kindly save your image generations accordingly


Inf-Edit endpoint result

Request

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

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

Body Attributes

ParameterDescription
keyYour API Key used for request authorization
promptText prompt with description of the things you want in the image to be generated.
source_promptText prompt with description of the things are already there in the image.
positive_promptItems you want in the image. [OPTIONAL]
widthWidth of your generated image. Max width: 2048px
heightHeight of your generated image. Max height: 2048px
target_blendText in prompt that needs to be blended/added to the image [OPTIONAL]
source_blendText in source_prompt which user want's to blend the changes with [OPTIONAL]
init_imageLink or provide valid base64 data which follows the format data:image/jpeg;base64,{your_base64_string} to the image you want your generations to resemble.
source_guidance_scaleScale for classifier-free guidance.
target_blend_threshScale for how much to blend the target_blend objects. float [0 to 1]
source_blend_threshScale for how much to blend the source_blend objects. float [0 to 1]
cross_replace_stepsCross attn control schedule, float [0 to 1]
num_inference_stepsNumber of denoising steps. Default 20. Max 50.
guidance_scaleScale for classifier-free guidance.
cross_replace_stepsCross attn control schedule, float [0 to 1]
self_replace_stepsSelf attn control schedule, float [0 to 1]
base64If provided image is in base64 format or if you want your generated images as a base64 string, must be set to true. Default: false.
strengthOptional. Prompt strength when using image. 1.0 corresponds to full destruction of information in the image.
webhookSet an URL to get a POST API call once the image generation is complete.
track_idThis ID is returned in the response to the webhook API call. This will be used to identify the webhook request.

Example

Body

Body
{
"key":"",
"prompt":"A anime girl with red hair and red eyes and shirt",
"source_prompt":"A anime girl with green hair and green eyes and shirt",
"target_blend":"red hair and red eyes",
"init_image":"https://sled-umich-infedit.hf.space/--replicas/7pnmc/file=/tmp/gradio/13838681b604a27bd2b7c81d1f1bf42359ad0b8b/miku.png",
"num_inference_steps":15,
"height":512,
"width":512,
"source_blend_thresh":0.8,
"target_blend_thresh":0.2,
"strength":0,
"source_blend":"shirt",
"cross_replace_steps":1,
"self_replace_steps":1,
"base64":false ,
"webhook": null,
"track_id": null
}

Request

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

var raw = JSON.stringify({
"key":"",
"prompt":"A anime girl with red hair and red eyes and shirt",
"source_prompt":"A anime girl with green hair and green eyes and shirt",
"target_blend":"red hair and red eyes",
"init_image":"https://sled-umich-infedit.hf.space/--replicas/7pnmc/file=/tmp/gradio/13838681b604a27bd2b7c81d1f1bf42359ad0b8b/miku.png",
"num_inference_steps":15,
"height":512,
"width":512,
"source_blend_thresh":0.8,
"target_blend_thresh":0.2,
"strength":0,
"source_blend":"shirt",
"cross_replace_steps":1,
"self_replace_steps":1,
"base64":false ,
"webhook": null,
"track_id": null
});

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

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

Response

Example Response

{
"status": "success",
"generationTime": 11.609652757644653,
"id": 33,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/temp/33957931-1e93-40a3-8c26-3d46492d9b49.png"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/temp/33957931-1e93-40a3-8c26-3d46492d9b49.png"
],
"meta": {
"base64": "no",
"cross_replace_steps": 1,
"file_prefix": "33957931-1e93-40a3-8c26-3d46492d9b49",
"guidance_scale": 2,
"height": 512,
"image": "https://sled-umich-infedit.hf.space/--replicas/7pnmc/file=/tmp/gradio/13838681b604a27bd2b7c81d1f1bf42359ad0b8b/miku.png",
"negative_prompt": "",
"num_inference_steps": 15,
"outdir": "out",
"positive_prompt": "",
"prompt": "A anime girl with red hair and red eyes and shirt",
"seed": 529348616,
"self_replace_steps": 1,
"source_blend": "shirt",
"source_blend_thresh": 0.8,
"source_guidance_scale": 1,
"source_prompt": "A anime girl with green hair and green eyes and shirt",
"strength": 0,
"target_blend": "red hair and red eyes",
"target_blend_thresh": 0.2,
"temp": "yes",
"width": 512
}
}