Generate Stunning Images with the cgrannon/lb12162024realistic Cognitive Action

21 Apr 2025
Generate Stunning Images with the cgrannon/lb12162024realistic Cognitive Action

In the world of image processing, the ability to generate and enhance images using AI is revolutionizing creative workflows. The cgrannon/lb12162024realistic API offers a powerful Cognitive Action called Generate Image with Inpainting. This action utilizes advanced inpainting techniques to create images based on specified prompts, masks, and a variety of customizable parameters. By leveraging these pre-built actions, developers can easily integrate sophisticated image generation capabilities into their applications, enhancing user engagement and creativity.

Prerequisites

Before you start using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON and RESTful API concepts.

Authentication generally involves passing your API key in the request headers. This allows you to securely access and utilize the available Cognitive Actions.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action is designed to create images by combining a source image, a mask, and a descriptive prompt. This action supports various models and allows customization of dimensions, quality, and formats to optimize image realism.

Input

The input schema for this action requires a JSON object with several fields. Here’s a breakdown of the required and optional parameters:

  • Required:
    • prompt (string): A detailed description for the image.
  • Optional:
    • mask (string): URI of the image mask for inpainting mode.
    • seed (integer): Random seed for reproducible outputs.
    • image (string): URI of the input image for inpainting.
    • model (string): Specifies the inference model (default: "dev").
    • width (integer): Width of the generated image (limited to specific conditions).
    • height (integer): Height of the generated image (limited to specific conditions).
    • accelerate (boolean): Run faster predictions (default: false).
    • megapixels (string): Approximate number of megapixels (default: "1").
    • aspectRatio (string): Determines the aspect ratio (default: "1:1").
    • imageFormat (string): Output image format (default: "webp").
    • outputCount (integer): Number of output images to generate (default: 1).
    • imageQuality (integer): Quality of saved images (default: 80).
    • guidanceScale (number): Guidance scale for the diffusion process.
    • promptInfluence (number): Strength of the prompt (default: 0.8).
    • mainLoraIntensity (number): Main LoRA application intensity.
    • inferenceStepCount (integer): Number of denoising steps (default: 28).
    • bypassSafetyChecker (boolean): Disable the safety checker.
    • additionalLoraWeights (string): Load additional LoRA weights.
    • additionalLoraIntensity (number): Extra LoRA application intensity.

Here’s an example input JSON payload:

{
  "model": "dev",
  "prompt": "photo of BUBR, a cute cat with her tongue out, mid transformation into an ultra instinct super saiyan god silver in a space coliseum in a void ",
  "accelerate": false,
  "megapixels": "1",
  "aspectRatio": "1:1",
  "imageFormat": "webp",
  "outputCount": 4,
  "imageQuality": 100,
  "guidanceScale": 4,
  "promptInfluence": 0.25,
  "mainLoraIntensity": 0.25,
  "inferenceStepCount": 40,
  "additionalLoraIntensity": 0.875
}

Output

Upon successful execution, the action returns an array of image URLs in the specified format. Here’s an example of the output you can expect:

[
  "https://assets.cognitiveactions.com/invocations/8fb2124d-770a-45d2-b6e5-a8412b301536/0297d79b-bfcd-484c-82cd-1da21c9d5d1d.webp",
  "https://assets.cognitiveactions.com/invocations/8fb2124d-770a-45d2-b6e5-a8412b301536/3d868439-6f4d-4e38-9c8e-870571e9fa14.webp",
  "https://assets.cognitiveactions.com/invocations/8fb2124d-770a-45d2-b6e5-a8412b301536/ffd4eaec-3850-470b-80f8-e20e0d12b16f.webp",
  "https://assets.cognitiveactions.com/invocations/8fb2124d-770a-45d2-b6e5-a8412b301536/382e455f-0d70-4548-9055-8ae2e051ee3c.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how to invoke the Generate Image with Inpainting action using Python:

import requests
import json

# Replace with your Cognitive Actions API key and endpoint
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute" # Hypothetical endpoint

action_id = "fd46e1f1-d42a-474d-b9ae-80f03f3f8062" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "photo of BUBR, a cute cat with her tongue out, mid transformation into an ultra instinct super saiyan god silver in a space coliseum in a void ",
    "accelerate": False,
    "megapixels": "1",
    "aspectRatio": "1:1",
    "imageFormat": "webp",
    "outputCount": 4,
    "imageQuality": 100,
    "guidanceScale": 4,
    "promptInfluence": 0.25,
    "mainLoraIntensity": 0.25,
    "inferenceStepCount": 40,
    "additionalLoraIntensity": 0.875
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json"
}

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json={"action_id": action_id, "inputs": payload} # Hypothetical structure
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully:")
    print(json.dumps(result, indent=2))

except requests.exceptions.RequestException as e:
    print(f"Error executing action {action_id}: {e}")
    if e.response is not None:
        print(f"Response status: {e.response.status_code}")
        try:
            print(f"Response body: {e.response.json()}")
        except json.JSONDecodeError:
            print(f"Response body: {e.response.text}")

In this snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id should match the ID of the action you want to execute. The JSON payload is structured according to the action's requirements.

Conclusion

The Generate Image with Inpainting action from the cgrannon/lb12162024realistic API provides developers with a robust tool for generating high-quality images based on detailed prompts. With customizable parameters, this action not only enhances creativity but also streamlines workflows in applications involving image generation. As you explore this powerful capability, consider experimenting with various parameters to achieve the desired results for your projects. Happy coding!