Scene

Learn how to control the quality and speed of image generation.

AI Background API provides you with three ways to create a background for your product:

  • Template-free approach

  • Template-based approach

  • Solid color background with product shadow only

Template-free options

In the template-free approach, only the prompts are used for background generation.

Prompt

AI Background API accepts text prompts to generate background. The prompt must be between 3 and 2048 characters.

Provide a detailed prompt to increase the likelihood of achieving the desired result.

{
    "scene": {
        "prompt": "on the wooden table in the dark room"
    }
}

Negative prompt

The negative prompt is a parameter that specifies what you don't want to see on the generated background. When specified, it tells the generation process not to include things in the image that match a given text. The negative_prompt must be between 3 and 2048 characters.

{
    "scene": {
        "prompt": "on the wooden table in the dark room",
        "negative_prompt": "pixelated, low quality"
    }
}

Color

If you want to change the color of the background, you can specify the desired color in hexadecimal format and it will be used as the main color.

Using color will make the resulting background look closer to the sample image.

{
    "scene": {
        "prompt": "on the wooden table in the dark room",
        "negative_prompt": "pixelated, low quality",
        "color": "#8fa782"
    }
}

Inference steps

The more inference steps you use, the better the results, but the more steps, the longer it takes to generate. If you want faster results, you can use fewer steps. If you want higher-quality results, you can use more steps.

{
    "scene": {
        "prompt": "on the wooden table in the dark room",
        "negative_prompt": "pixelated, low quality",
        "color": "#8fa782",
        "steps": 20
    }
}

Aspect ratio

By default, the aspect ratio is 1:1 with dimensions of 1024x1024px. But you can change it to any of the following values, listed from wider to taller:

If you need a size larger than the generation result, you can upscale. See Upscale for more info.

{
    "scene": {
        "prompt": "on the wooden table in the dark room",
        "negative_prompt": "pixelated, low quality",
        "color": "#8fa782",
        "steps": 20,
        "aspect_ratio": "16:9"
    }
}

Possible values

Template-based approach

In the template-based approach, you can use a sample image that will be used to generate a background similar to the image, and you can also use prompts to increase the likelihood of achieving the desired result.

Template image

AI Background API supports several options to provide sample images that will be used to generate background.

If you upload a non-square image, it will be scaled and cropped to fit a square.

HTTP(S) URL

URL of the input image should be from 1 to 4096 characters. The image must be accessible by our system.

{
    "scene": {
        "template_url": "https://images.claid.ai/photoshoot-templates/docs/scene.png"
    }
}

Connected storage

You can connect Cloud Storage and use it as a source for images. Currently, our API supports AWS S3 and Google Cloud Storage.

After connecting your Cloud Storage, you can refer the storage name as an input.

{
    "scene": {
        "template_url": "storage://storage-name/path/scene.png"
    }
}

Input image file types

The API supports the following image formats as inputs: BMP, GIF, JPEG, PNG, TIFF, WEBP, AVIF, and HEIC.

Template mode

The template mode enables you to determine the degree of similarity between the background and the template image. You can select between lock mode to preserve maximum details, adjust mode to slightly adjust the background to better match the product, or transform mode to freely transform the background with prompt and color parameters. See Color and Prompts for more info.

prompt, color and steps are unavailable for lock template mode. color is unavailable for adjust template mode.

transform template mode is used by default.

{
    "scene": {
        "template_url": "storage://storage-name/path/scene.png",
        "template_mode": "lock"
    }
}

Template viewpoint

The template viewpoint describes the camera position and tilt angle from which the photo was taken. Available viewpoints are listed below:

front viewpoint is used by default.

{
    "scene": {
        "template_url": "storage://storage-name/path/scene.png",
        "view": "top"
    }
}

Prompts

You can use prompt and negative_prompt in the same way as in the template-free approach, but prompt is not a required parameter for template-based approach.

Color

You can use color in the same way as in the template-free approach, and color is not a required parameter for template-based approach as well. If specified, color will be used as the main color of the image sample-based background.

Inference steps

You can use steps in the same way as in the template-free approach, and again, steps is not a required parameter for the template-based approach. By default, each template_mode has an optimal steps value. And steps is not available for lock mode.

Possible values

Limitations

The template image viewpoint (camera position and tilt angle from which the photo was taken) should match the viewpoint of the product image.

Product Shadows

Shadows generation mode covers the straightforward yet highly popular scenario in product photography. Creating a shadow effect for a product on transparent or on a solid Color can enhance its appearance. A product on a white background, for instance, looks better with a shadow.

{
    "scene": {
        "effect": "shadows",
        "color": "#d3d3d3",
        "view": "top"
    }
}

The shadow generation effect requires View parameter. Color parameter is optional and omitting it will leave the background of the result image transparent.

Limitations

Background with product shadows does not require placement for the Object, so you don't need to pass any of placement related parameters in request payload. Object payload should be:

{
    "object": {
        "image_url": "https://images.claid.ai/photoshoot-templates/docs/product.png"
    }
}

Last updated