Image Mixer Endpoint
Overview
This endpoint generates image by mixing multiple images.
Together with the image you can add your description of the desired result by passing prompt and negative prompt.
Request
--request POST 'https://modelslab.com/api/v6/image_editing/img_mixer' \
Make a POST
request to https://modelslab.com/api/v6/image_editing/img_mixer 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 with description of the things you want in the image to be generated | string |
negative_prompt | Items you don't want in the image | string |
init_image | Comma-separated image URLs of images to mix | URL |
width | The width of the image. Max: 1024 pixels | integer |
height | The height of the image. Max: 1024 pixels | integer |
steps | Number of denoising steps. Min: 1. Max: 50 | integer |
guidance_scale | Scale for classifier-free guidance. Min: 1. Max: 20 | float |
init_image_weights | Weights of the images being passed, separated by commas. | 0.1 to 1, separated by commas |
seed | Seed used to reproduce results. Same seed will give you the same image again. Pass null for a random number | integer, null |
samples | Number of images to be returned in response. Max: 1 | integer |
webhook | Set a URL to receive a POST API call once the image generation is complete | URL |
track_id | This ID is returned in the response to the webhook API call and will be used to identify the webhook request | integer |
Example
Body
Body
{
"key":"",
"seed":12345,
"init_image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png",
"prompt":"rose man",
"negative_prompt":"A polluted city",
"init_image_weights":"0.5,0.7",
"width":800,
"height":600,
"guidance_scale":10,
"steps":41,
"samples":1
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"init_image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png",
"seed":"12345",
"prompt":"rose man",
"negative_prompt":"A polluted city",
"init_image_weights":"0.5,0.7",
"width":800,
"height":600,
"guidance_scale":10,
"steps":41,
"samples":1,
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v6/image_editing/img_mixer", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"init_image" => "https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png",
"seed" => "12345",
"prompt" => "rose man",
"negative_prompt" => "A polluted city",
"init_image_weights" => "0.5,0.7",
"width" => 800,
"height" => 600,
"guidance_scale" => 10,
"steps" => 41,
"samples" => 1,
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/image_editing/img_mixer',
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/img_mixer',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"init_image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png",
"seed":"12345",
"prompt":"rose man",
"negative_prompt":"A polluted city",
"init_image_weights":"0.5,0.7",
"width":800,
"height":600,
"guidance_scale":10,
"steps":41,
"samples":1,
"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/img_mixer"
payload = json.dumps({
"key": "",
"init_image":"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png",
"seed":"12345",
"prompt":"rose man",
"negative_prompt":"A polluted city",
"init_image_weights":"0.5,0.7",
"width":800,
"height":600,
"guidance_scale":10,
"steps":41,
"samples":1
"seed": None,
"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 \"seed\":12345,\n \"init_image\":\"https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png\",\n \"prompt\":\"rose man\",\n \"negative_prompt\":\"A polluted city\",\n \"init_image_weights\":\"0.5,0.7\",\n \"width\":800,\n \"height\":600,\n \"guidance_scale\":10,\n \"steps\":41,\n \"samples\":1\n \n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/image_editing/img_mixer")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 19.260561227798462,
"id": 349,
"output": [
"https://cdn2.stablediffusionapi.com/generations/8aa6cb76-0c62-4ebc-a29a-3a3e3727bc88-0.png"
],
"meta": {
"H": 600,
"W": 800,
"file_prefix": "8aa6cb76-0c62-4ebc-a29a-3a3e3727bc88",
"guidance_scale": 10,
"init_image": "https://img.freepik.com/premium-photo/red-roses-rose-petals-white-backgroundvalentines-day-concept_167862-5720.jpg,https://huggingface.co/datasets/diffusers/test-arrays/resolve/main/stable_diffusion_inpaint/boy.png",
"init_image_weights": "0.5,0.7",
"n_samples": 1,
"negative_prompt": "A polluted city",
"outdir": "out",
"prompt": "rose man",
"seed": 12345,
"steps": 41
}
}