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
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
Parameter | Description |
---|---|
key | Your API Key used for request authorization |
prompt | Text prompt with description of the things you want in the image to be generated. |
source_prompt | Text prompt with description of the things are already there in the image. |
positive_prompt | Items you want in the image. [OPTIONAL] |
width | Width of your generated image. Max width: 2048px |
height | Height of your generated image. Max height: 2048px |
target_blend | Text in prompt that needs to be blended/added to the image [OPTIONAL] |
source_blend | Text in source_prompt which user want's to blend the changes with [OPTIONAL] |
init_image | Link 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_scale | Scale for classifier-free guidance. |
target_blend_thresh | Scale for how much to blend the target_blend objects. float [0 to 1] |
source_blend_thresh | Scale for how much to blend the source_blend objects. float [0 to 1] |
cross_replace_steps | Cross attn control schedule, float [0 to 1] |
num_inference_steps | Number of denoising steps. Default 20. Max 50. |
guidance_scale | Scale for classifier-free guidance. |
cross_replace_steps | Cross attn control schedule, float [0 to 1] |
self_replace_steps | Self attn control schedule, float [0 to 1] |
base64 | If provided image is in base64 format or if you want your generated images as a base64 string, must be set to true . Default: false . |
strength | Optional. Prompt strength when using image. 1.0 corresponds to full destruction of information in the image. |
webhook | Set an URL to get a POST API call once the image generation is complete. |
track_id | This 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
- JS
- PHP
- NODE
- PYTHON
- JAVA
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));
<?php
$payload = [
"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,
"track_id" => null,
"webhook" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/image_editing/inf_edit',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v6/image_editing/inf_edit',
'headers': {
'Content-Type': 'application/json'
},
body: 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
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v6/image_editing/inf_edit"
payload = json.dumps({
"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": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\"key\":\"\",\n\"prompt\":\"A anime girl with red hair and red eyes and shirt\",\n\"source_prompt\":\"A anime girl with green hair and green eyes and shirt\",\n\"target_blend\":\"red hair and red eyes\",\n\"init_image\":\"https://sled-umich-infedit.hf.space/--replicas/7pnmc/file=/tmp/gradio/13838681b604a27bd2b7c81d1f1bf42359ad0b8b/miku.png\",\n\"num_inference_steps\":15,\n\"height\":512,\n\"width\":512,\n\"source_blend_thresh\":0.8,\n\"target_blend_thresh\":0.2,\n\"strength\":0,\n\"source_blend\":\"shirt\",\n\"cross_replace_steps\":1,\n\"self_replace_steps\":1,\n\"base64\":false\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/image_editing/inf_edit")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
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
}
}