Generate Stunning Images with Inpainting using odddgarden/baodashone Cognitive Actions

21 Apr 2025
Generate Stunning Images with Inpainting using odddgarden/baodashone Cognitive Actions

In the realm of creative image synthesis, the odddgarden/baodashone API provides an impressive array of Cognitive Actions that enable developers to generate and customize images with ease. Among these actions, the ability to create images with inpainting modes stands out, allowing for tailored modifications in aspect ratios, image quality, and generation speed. By leveraging these pre-built actions, developers can save time and effort while enhancing their applications with advanced image processing capabilities.

Prerequisites

Before diving into the specifics of the Cognitive Actions, ensure you have the following:

  • An API key to access the Cognitive Actions platform.
  • Familiarity with JSON payloads and RESTful API concepts.

For authentication, you will typically pass the API key in the headers of your requests. This allows secure access to the Cognitive Actions services.

Cognitive Actions Overview

Generate Image with Inpainting

Description:
This action generates images using inpainting modes, enabling customization of various parameters including aspect ratio, image quality, and generation speed. It utilizes advanced models named 'dev' and 'schnell' for optimal performance.

Category: Image Generation

Input:

The Generate Image with Inpainting action requires a JSON payload structured as follows:

{
  "prompt": "A character sheet of BAODASHONE, a chubby bull wearing a suit and tie, front back and side view, 3D animated character",
  "goFast": false,
  "loraScale": 1,
  "modelType": "dev",
  "numOutputs": 1,
  "guidanceScale": 3,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "imageAspectRatio": "16:9",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28,
  "additionalLoraIntensity": 1
}
  • Required Fields:
    • prompt: A description that guides the image generation.
  • Optional Fields:
    • goFast: Enables faster predictions.
    • loraScale: Determines the strength of the main LoRA application.
    • modelType: Specifies which model to use ('dev' or 'schnell').
    • numOutputs: Number of images to generate.
    • guidanceScale: Influences the diffusion process for image realism.
    • outputQuality: Quality of the output images.
    • promptStrength: Strength for prompt when using image-to-image.
    • imageMegapixels: Approximate number of megapixels for the image.
    • imageAspectRatio: The aspect ratio for the generated image.
    • imageOutputFormat: Format of the output image.
    • numInferenceSteps: Number of steps in the denoising process.
    • additionalLoraIntensity: Strength of any additional LoRA application.

Output:

Upon successful execution, the action returns a link to the generated image. For example, the output might look like this:

[
    "https://assets.cognitiveactions.com/invocations/dbb64877-aec3-4119-a8ff-89b7dabf184f/3e04a10a-5ada-43e5-b88f-325feaf809a9.webp"
]

This URL points to the newly created image, ready to be used in your application.

Conceptual Usage Example (Python):

Here’s how you can utilize the Generate Image with Inpainting action in your Python code:

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 = "31cb85ca-c10e-4e5a-adc5-6d0e3c1220eb"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "goFast": false,
    "prompt": "A character sheet of BAODASHONE, a chubby bull wearing a suit and tie, front back and side view, 3D animated character",
    "loraScale": 1,
    "modelType": "dev",
    "numOutputs": 1,
    "guidanceScale": 3,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "imageAspectRatio": "16:9",
    "imageOutputFormat": "webp",
    "numInferenceSteps": 28,
    "additionalLoraIntensity": 1
}

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 code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable contains the necessary parameters as outlined in the input schema. The action_id is set to match the ID for the Generate Image with Inpainting action.

Conclusion

The odddgarden/baodashone Cognitive Actions offer powerful functionalities for developers looking to enhance their applications with advanced image generation capabilities. The Generate Image with Inpainting action allows for extensive customization, making it an excellent choice for creative projects. With the examples and guidance provided, you're now equipped to start integrating these actions into your applications. Explore the possibilities and let your creativity shine!