POST/v1/sd1.5-controlnet-depth
1const axios = require('axios');
2
3const fs = require('fs');
4const path = require('path');
5
6async function toB64(imgPath) {
7    const data = fs.readFileSync(path.resolve(imgPath));
8    return Buffer.from(data).toString('base64');
9}
10
11const api_key = "YOUR API-KEY";
12const url = "https://api.segmind.com/v1/sd1.5-controlnet-depth";
13
14const data = {
15  "image": "toB64('https://segmind.com/depth.jpeg')",
16  "samples": 1,
17  "prompt": "young african american man, black suit, smiling, white background",
18  "negative_prompt": "mangled ears, Disfigured, cartoon, blurry, nude",
19  "scheduler": "UniPC",
20  "num_inference_steps": 25,
21  "guidance_scale": 7.5,
22  "strength": 1,
23  "seed": 9715432854,
24  "base64": false
25};
26
27(async function() {
28    try {
29        const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
30        console.log(response.data);
31    } catch (error) {
32        console.error('Error:', error.response.data);
33    }
34})();
RESPONSE
image/jpeg
HTTP Response Codes
200 - OKImage Generated
401 - UnauthorizedUser authentication failed
404 - Not FoundThe requested URL does not exist
405 - Method Not AllowedThe requested HTTP method is not allowed
406 - Not AcceptableNot enough credits
500 - Server ErrorServer had some issue with processing
Expand

Attributes


imageimage *

Input Image


samplesint ( default: 1 ) Affects Pricing

Number of samples to generate.

min : 1,

min : 4


promptstr *

Prompt to render


negative_promptstr ( default: None )

Prompts to exclude, eg. 'bad anatomy, bad hands, missing fingers'


schedulerenum:str ( default: UniPC )

Type of scheduler.

Allowed values:


num_inference_stepsint ( default: 20 ) Affects Pricing

Number of denoising steps.

min : 20,

min : 100


guidance_scalefloat ( default: 7.5 )

Scale for classifier-free guidance

min : 0.1,

min : 25


strengthfloat ( default: 1 )

How much to transform the reference image

min : 0.1,

min : 1


seedint ( default: -1 )

Seed for image generation.


base64boolean ( default: 1 )

Base64 encoding of the output image.

To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.

ControlNet Depth

ControlNet Depth model, a revolutionary tool that brings depth and dimensionality to images. The ControlNet Depth model delves deeper, creating a depth map from your input image. This results in stunningly realistic images that seem to leap off the screen, offering a visual experience that's both immersive and captivating.

The ControlNet Depth model is engineered to render depth, transforming flat images into dynamic visuals. By analyzing masks, the model discerns the varying levels of depth in an image, producing a depth map that adds layers of realism. However, this intricate process sometimes leads the model to infer additional information based on the object's shape, which can introduce unexpected elements into the rendered image.

Advantages

  1. Depth Rendering: Transforms 2D images into depth-rich visuals, adding a layer of realism.

  2. Dynamic Visuals: Creates images that seem to pop off the page, enhancing viewer engagement.

  3. Advanced Mask Analysis: By analyzing masks, the model can discern and render depth intricacies in images.

  4. Adaptive Learning: The model's training allows it to make depth inferences, though this can sometimes lead to unexpected results with unnatural images.

Use Cases

  1. 3D Visualization: Ideal for projects that require depth visualization, such as architectural designs or product showcases.

  2. Artistic Renderings: Artists can leverage the depth model to create dynamic artworks that captivate viewers.

  3. Augmented Reality (AR) and Virtual Reality (VR): Enhance user immersion by adding depth to virtual environments.

  4. Image Editing: Add depth to flat images, transforming them into lifelike visuals.

ControlNet Depth License

ControlNet Depth, in its commitment to ethical AI practices, has embraced the CreativeML OpenRAIL M license. This decision not only underscores the model's dedication to responsible AI but also aligns it with the principles set forth by BigScience and the RAIL Initiative. Their collaborative work in AI ethics and responsibility has set the benchmark for licenses like the OpenRAIL M.