Skip to main content

Blip Diffusion Endpoint

Overview

This endpoint allow you to perform blip diffusion on image passed. It works best for object

Blip-Diffusion endpoint result

Request

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

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

Body Attributes

ParameterDescriptionValues
keyYour API Key used for request authorizationkey
promptText prompt with a description of the things you want in the image to be generatedstring
negative_promptItems you don't want in the imagestring
taskThe task to execute. Default is zeroshotOptions: zeroshot, controlnet_generation, controlnet_scribble_generation
condition_imageRequired when task is zeroshotURL
condition_subjectRequired when task is zeroshot. It is the subject from the condition imagestring
target_subjectObject expected in the resultstring
style_subjectRequired when task is controlnet_generation or controlnet_scribble_generation. It is the subject from the style imagestring
controlnet_condition_imageImage URL of the controlnet condition image. Used when task is controlnet_generation or controlnet_scribble_generation. For controlnet_scribble_generation, provide the canny image URL instead of just the imageURL
widthThe width of the image. Max Height: Width: 512 x 512The maximum is 512 pixels
heightThe height of the image. Max Height: Height: 512 x 512The maximum is 512 pixels
guidance_scaleOptional. Scale for classifier-free guidance. Default is 8Minimum: 1, Maximum: 20
stepsNumber of denoising steps. Default is 20Minimum: 1, Maximum: 50
seedSeed is used to reproduce results, same seed will give you the same image in return again. Pass null for a random numberIntegral value
webhookSet a URL to get a POST API call once the image generation is completeURL
track_idThis ID is returned in the response to the webhook API call. This will be used to identify the webhook requestIntegral value

Example

Body

When task is zeroshot, the request will look like so;

Body
{
"key":"",
"seed":88888,
"task":"zeroshot",
"prompt":"on a marble table",
"condition_image":"https://m.media-amazon.com/images/I/61qEOpxc1WL.jpg",
"condition_subject":"teapot",
"target_subject":"school bag",
"guidance_scale":7.5,
"steps":35,
"height":512,
"width":512,
"webhook": null,
"track_id": null
}

When task is controlnet_generation, the request will look like so

Body
{
"key":"",
"seed":88888,
"task":"controlnet_generation",
"prompt":"on a marble table",
"style_image":"https://m.media-amazon.com/images/I/61qEOpxc1WL.jpg",
"controlnet_condition_image":"https://m.media-amazon.com/images/I/81ELJHbkafL._AC_SX569_.jpg",
"style_subject":"teapot",
"target_subject":"cup",
"guidance_scale":10,
"steps":35,
"height":512,
"width":512,
"webhook": null,
"track_id": null
}

When task is controlnet_scribble_generation, the request will look like so

Body
{
"key":"",
"seed":88888,
"task":"controlnet_generation",
"prompt":"on a marble table",
"style_image":"//huggingface.co/datasets/ayushtues/blipdiffusion_images/resolve/main/flower.jpg",
"controlnet_condition_image":"https://huggingface.co/lllyasviel/sd-controlnet-scribble/resolve/main/images/bag.png",
"style_subject":"flower",
"target_subject":"bag",
"guidance_scale":10,
"steps":35,
"height":512,
"width":512,
"webhook": null,
"track_id": null
}

Request

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

var raw = JSON.stringify({
"key":"",
"seed":88888,
"task":"zeroshot",
"prompt":"on a marble table",
"condition_image":"https://m.media-amazon.com/images/I/61qEOpxc1WL.jpg",
"condition_subject":"teapot",
"target_subject":"school bag",
"guidance_scale":7.5,
"steps":35,
"height":512,
"width":512,
"webhook": null,
"track_id": null
});

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

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

Response

Example Response

{
"status": "success",
"generationTime": 3.270559072494507,
"id": 563,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/9c1e05cc-16f0-4a11-9900-a6edd56586dd.png.png"
],
"meta": {
"base64": "no",
"file_prefix": "9c1e05cc-16f0-4a11-9900-a6edd56586dd.png",
"guidance_scale": 7.5,
"height": 512,
"instant_response": "no",
"neg_prompt": "over-exposure, under-exposure, saturated, duplicate, out of frame, lowres, cropped, worst quality, low quality, jpeg artifacts, morbid, mutilated, out of frame, ugly, bad anatomy, bad proportions, deformed, blurry, duplicate",
"num_inference_steps": 35,
"outdir": "out",
"prompt": "on a marble table",
"prompt_reps": 20,
"prompt_strength": 1,
"reference_image": "https://m.media-amazon.com/images/I/61qEOpxc1WL.jpg",
"seed": 88888,
"source_subject_category": "teapot",
"sub_task": "zeroshot",
"target_subject_category": "shoe",
"temp": "no",
"width": 512
}
}