Generate Stunning Images with Inpainting Using the doctorparadox/hannah-arendt Actions

23 Apr 2025
Generate Stunning Images with Inpainting Using the doctorparadox/hannah-arendt Actions

In the world of AI and machine learning, the ability to generate and manipulate images has become a pivotal feature in many applications. The doctorparadox/hannah-arendt Cognitive Actions offer a powerful solution for developers looking to create and enhance images through inpainting. These pre-built actions simplify the image generation process by allowing developers to focus on the creative aspects while leveraging sophisticated models optimized for performance and quality.

Prerequisites

Before you dive into using the Cognitive Actions, ensure that you have the following:

  • An API key for the Cognitive Actions platform.
  • A basic understanding of JSON and how to structure API requests.
  • Familiarity with Python and the requests library for making HTTP calls.

To authenticate your requests, you will typically include your API key in the headers of your HTTP request.

Cognitive Actions Overview

Generate Image with Inpainting

Purpose

The Generate Image with Inpainting action allows you to create images based on a textual prompt while providing various parameters to control the image's attributes, such as dimensions, quality, and model choice. This is especially useful for applications requiring custom image generation based on user input or specific themes.

Input

The action requires the following fields in its input schema:

  • prompt (required): A descriptive text for the image, such as "a portrait of Hannah ARENDT".
  • model (optional): Choose between "dev" (for quality) and "schnell" (for speed).
  • megapixels (optional): Specify the approximate number of megapixels for the image.
  • guidanceScale (optional): Set the guidance scale for the diffusion process, affecting realism.
  • enableFastMode (optional): Opt for faster predictions.
  • promptStrength (optional): Strength of the prompt influence on the generated image.
  • numberOfOutputs (optional): Define how many images to generate (up to 4).
  • imageOutputFormat (optional): Choose the format for the output image (e.g., "webp", "jpg", "png").
  • aspectRatioSetting (optional): Set the aspect ratio of the generated image.
  • imageOutputQuality (optional): Define the quality of the output image.

Example Input:

{
  "model": "dev",
  "prompt": "a portrait of Hannah ARENDT",
  "megapixels": "1",
  "guidanceScale": 3,
  "enableFastMode": false,
  "promptStrength": 0.8,
  "loraWeightScale": 1,
  "numberOfOutputs": 1,
  "imageOutputFormat": "webp",
  "aspectRatioSetting": "3:4",
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Output

The action returns a URL pointing to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/93531866-3173-4c89-890e-c529397b33bd/35e51091-9373-4fea-9e38-ad75a7b15348.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call 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 = "3a2c2a7d-d219-4561-bfe6-0c21f38fda75" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "a portrait of Hannah ARENDT",
    "megapixels": "1",
    "guidanceScale": 3,
    "enableFastMode": False,
    "promptStrength": 0.8,
    "loraWeightScale": 1,
    "numberOfOutputs": 1,
    "imageOutputFormat": "webp",
    "aspectRatioSetting": "3:4",
    "imageOutputQuality": 80,
    "additionalLoraScale": 1,
    "numberOfInferenceSteps": 28
}

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 action_id specifies which action you're calling. The payload is structured according to the input schema detailed above.

Conclusion

The doctorparadox/hannah-arendt Cognitive Actions provide developers with a robust framework for generating and manipulating images efficiently. With the ability to customize parameters such as aspect ratio, quality, and model choice, you can create stunning visuals tailored to your application’s needs. Explore further use cases by integrating these actions into your projects, and unleash your creativity!