Relighting Endpoint
Overview
This endpoint helps to create lighting around image
Request
--request POST 'https://modelslab.com/api/v6/image_editing/relighting' \
Make a POST
request to https://modelslab.com/api/v6/image_editing/relighting endpoint and pass the required parameters as a request body to the endpoint.
Body Attributes
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization | string |
prompt | Text prompt describing the content you want in the generated image | string |
negative_prompt | Items you do not want in the image | string |
init_image | Link or valid base64 data of the image you want your generations to resemble | data:image/jpeg;base64,{your_base64_string} |
width | Width of the generated image. Maximum dimension: 1024 x 1024 pixels | integer |
height | Height of the generated image. Maximum dimension: 1024 x 1024 pixels | integer |
lighting | How the lighting should be placed | none, left, right, top, bottom |
guidance_scale | Scale for classifier-free guidance. Minimum: 1, Maximum: 20. Default: 7 | integer |
highres_scale | High-resolution scale. Default: 1.5 | float |
lowres_denoise | Low-resolution denoise. Default: 0.9 (max: 1) | float |
highres_denoise | High-resolution denoise. Default: 0.5 (max: 1) | float |
num_inference_steps | Number of denoising steps. Default: 20, Maximum: 50 | integer |
base64 | Set to true if the provided image is in base64 format or if you want generated images as base64 string | TRUE or FALSE |
seed | Seed used to reproduce results. Pass null for a random number. | integral value |
samples | Number of images to be returned in response. Maximum value is 2 | integer (max: 2) |
webhook | URL to receive a POST API call once the image generation is complete | URL |
track_id | ID returned in the response to the webhook API call, used to identify the webhook request | integral value |
Example
Body
Body
{
"key":"",
"init_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png",
"lighting": "right",
"prompt": "woman, detailed, neon lighting",
"height": 512,
"width": 1024,
"samples":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":"",
"init_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png",
"lighting": "right",
"prompt": "woman, detailed, neon lighting",
"height": 512,
"width": 1024,
"samples":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/relighting", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key":"",
"init_image" =>"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png",
"lighting" => "right",
"prompt" => "woman, detailed, neon lighting",
"height" => 512,
"width" => 1024,
"samples" => 1,
"base64" => false,
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/image_editing/relighting',
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/relighting',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key":"",
"init_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png",
"lighting": "right",
"prompt": "woman, detailed, neon lighting",
"height": 512,
"width": 1024,
"samples":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/relighting"
payload = json.dumps({
"key":"",
"init_image":"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png",
"lighting": "right",
"prompt": "woman, detailed, neon lighting",
"height": 512,
"width": 1024,
"samples":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, "{\r\n \"key\":\"\",\r\n \"init_image\":\"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png\",\r\n \"lighting\": \"right\",\r\n \"prompt\": \"woman, detailed, neon lighting\",\r\n \"height\": 512,\r\n \"width\": 1024,\r\n \"samples\":1,\r\n \"base64\":false\r\n\r\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/image_editing/relighting")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 7.328356504440308,
"id": 67,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/f5a759d2-9af0-4965-8894-7e4433ee76e9-0.png"
],
"proxy_links": [
"https://cdn2.stablediffusionapi.com/generations/f5a759d2-9af0-4965-8894-7e4433ee76e9-0.png"
],
"meta": {
"base64": "no",
"file_prefix": "f5a759d2-9af0-4965-8894-7e4433ee76e9",
"guidance_scale": 7,
"height": 512,
"highres_denoise": 0.5,
"highres_scale": 1.5,
"init_image": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/e7d2dd6f-9482-40df-a910-89cc4de2e7b6-0.png",
"lighting": "right",
"lowres_denoise": 0.9,
"negative_prompt": "low quality",
"num_inference_steps": 20,
"outdir": "out",
"prompt": "woman, detailed, neon lighting",
"samples": 1,
"seed": -1,
"temp": "no",
"width": 1024
}
}