API Documentation
  • Welcome!
  • Quick Start
  • API methods
  • Easy integration
  • Handling Large File Sets
  • Supported formats
  • Webhooks
  • Common usecases
    • Auto enhance image quality
    • Create business photo or avatar from face image
    • Face swap
    • Create beautiful product photo
    • Genarate image in high resolution
    • Remove background
    • AI Drawing to Image - Doodle
    • Real estate
    • Enhancing documents
    • Car dealer photo
  • Image processing
    • Resize and padding
    • Denoise and sharpen
    • Enhance lighting and colors
    • Enhance face details
    • Background removal and generation
    • Image generation
    • Inpainting and outpainting (uncrop)
    • Frame identification
    • Print
    • Captions
    • Additional parameters
    • Presets
  • Account & settings
    • Account information
  • storages
    • Description
    • AWS S3
    • AWS S3 IAM Configuration
  • Presets
    • E-commerce
    • Real-estate
    • Print/Photo
    • Digital Art
  • Technology
    • Algorithms
    • Upscale
    • Background removal
      • Remove BG recommendation
    • Sharpen & Noise reduction
    • Enhance Lighting
  • FAQ
Powered by GitBook
On this page
  • Background/generate parameters
  • Based on text only
  • Based on image
  • Generative upscaling
  1. Image processing

Image generation

Background/generate parameters

Let's see all the parameters of background generate section that can be used in image generation API. They will be described in detail down below.

Field name
Description

model_type

This parameter chooses model which will be used for image generation, realistic is the default one: - realistic - fantasy

description

Generation prompt. By default "high quality, highly detailed, 8K" phrase is added to it.

sample_num

Works like generator random seed.

adapter_type

This parameter controls how generator will use the input image.

  • generate_background - (default value) background is generated around the main object found in the input image

  • face - generator will use first found face of the input image to create an avatar

  • control - (also known as "image to image") generator will generate image based on image and image edges, it's useful for adding details to existing photos, f.e. adding furniture to empty room

  • control2 - generator will generate image based only on image edges, it's useful for generating images from drawings

  • upscale - used for specifying prompts for generative upscale

face_id

true/false - Works only when adapter_type is face. Selects different face generation algorithm when just face details are used (skips for example hair style from original photo).

controlnet_conditioning_scale

Float value from 0 to 1 describes how much edges will be preserved. Default value is 0.5

Let's check some examples.

Based on text only

Image can be generated based on text prompt in given resolution.

{
    "width": 2048,
    "height": 1024,
    "background": {
        "generate": {
            "description": "woman in a futuristic suit holding a gun in her hand, looking at the camera, cyberpunk art, neo-figurative, anime"
        }
    }
}

And the result:

Now, the same prompt but with fantasy model:

{
    "width": 2048,
    "height": 1024,
    "background": {
        "generate": {
            "description": "woman in a futuristic suit holding a gun in her hand, looking at the camera, cyberpunk art, neo-figurative, anime",
            "model_type": "fantasy"
        }
    }
}

Based on image

Images can be generated based on face details or image canny edges.

Let's check some examples.

{
    "url": "https://deep-image.ai/api-example.png",
    "width": 1024,
    "height": 1024,
    "background": {
        "generate": {
            "description": "item on the beach",
            "adapter_type": "generate_background"
        }
    }
}

And the result

{
    "url": "https://deep-image.ai/api-example3.jpg",
    "width": 1024,
    "height": 1024,
    "background": {
        "generate": {
            "description": "model on the beach",
            "adapter_type": "face"
        }
    }
}

And the result

{
    "url": "https://deep-image.ai/api-example3.jpg",
    "background": {
        "generate": {
            "description": "model in the room",
            "adapter_type": "control"
        }
    }
}

And the result

Generative upscaling

{
    "url": "https://deep-image.ai/api-example.png",
    "width": 3000,
    "generative_upscale": true
}
curl --request POST \
     --url https://deep-image.ai/rest_api/process_result \
     --header 'content-type: application/json' \
     --header 'x-api-key: API_KEY' \
     --data '{
         "url": "https://deep-image.ai/api-example.png",
         "width": 3000,
         "generative_upscale": true
      }'
import os

import deep_image_ai_client

configuration = deep_image_ai_client.Configuration(
    host="https://deep-image.ai"
)

configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

with deep_image_ai_client.ApiClient(configuration) as api_client:
    api_instance = deep_image_ai_client.DefaultApi(api_client)
    process_payload = {"url": "https://deep-image.ai/api-example.jpg", "width": 3000, generative_upscale: True}
    api_response = api_instance.rest_api_process_result_post(process_payload)

And the result:

PreviousBackground removal and generationNextInpainting and outpainting (uncrop)

Last updated 6 months ago

inpainting - described in

Let's try to use generative upscaling. This algorithm can do some real magic . It also modifies image slightly because it's based on diffusion algorithm so do not use it when you really want to preserve exact image colors and original image details.

🙂
separated chapter
Generative upscale result
Page cover image