Create Stunning Images with Ingolf's Inpainting Action

25 Apr 2025
Create Stunning Images with Ingolf's Inpainting Action

In the world of digital creativity, the ability to generate and manipulate images quickly and effectively can set your projects apart. Ingolf’s “Generate Image with Inpainting” action empowers developers to create high-quality images through advanced inpainting techniques. This action allows for customizable parameters such as aspect ratio, output quality, and guidance scale, making it an ideal tool for artists, designers, and content creators looking to enhance their visual storytelling.

With support for image-to-image transformations and mask applications, Ingolf streamlines the process of image editing and generation, delivering faster predictions with the optimized 'schnell' model. Whether you're creating unique visuals for marketing campaigns, generating art for games, or simply experimenting with AI-generated imagery, this action opens up a world of possibilities.

Prerequisites

Before getting started, ensure you have an API key for Cognitive Actions and a basic understanding of making API calls.

Generate Image with Inpainting

The "Generate Image with Inpainting" action is designed to create images using inpainting techniques, allowing for significant customization. It solves the problem of needing quick, high-quality image generation that can be tailored to specific project needs.

Input Requirements

To use this action, you will need to provide a structured input that includes:

  • prompt: A descriptive text that guides the image generation process (required).
  • mask: A URI for the image mask (optional but overrides width and height).
  • image: A URI for the input image (optional for image-to-image transformations).
  • width and height: Dimensions for the generated image (if using custom aspect ratios).
  • Additional parameters like outputCount, mainLoraScale, enableFastMode, and more to fine-tune the output.

Example Input

{
  "prompt": "INGOLF stands alone on a long, empty road stretching into the distance...",
  "outputCount": 1,
  "mainLoraScale": 1,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "imageMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "imageGuidanceScale": 3,
  "imageOutputQuality": 80,
  "inferenceStepCount": 30,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8
}

Expected Output

The action will return a URL to the generated image, which could look like this:

[
  "https://assets.cognitiveactions.com/invocations/15515a21-d186-48d9-aa05-6108ea3ce65a/f9608aaf-0eb4-4a6a-945a-a8aa5ecde3e8.png"
]

Use Cases for This Action

  • Marketing Materials: Quickly generate unique images tailored to specific campaigns or branding needs.
  • Art and Design: Artists can create original pieces or iterate on existing images with new elements.
  • Game Development: Generate concept art or in-game assets efficiently, allowing for rapid prototyping.
  • Personal Projects: Experiment with visual ideas or create custom graphics for blogs and social media.

```python
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "f65080c1-4c19-433a-9c55-ff6f6f754b26" # Action ID for: Generate Image with Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "INGOLF stands alone on a long, empty road stretching into the distance. He wears a sleek but understated suit, his jacket open, symbolizing determination and self-leadership. His gaze is directed towards the camera. The scene is bathed in soft morning light—a moment of reflection and inner strength. The background remains minimalistic, a quiet yet powerful symbol of the personal journey of leadership.",
  "outputCount": 1,
  "mainLoraScale": 1,
  "enableFastMode": false,
  "inferenceModel": "dev",
  "imageMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "imageGuidanceScale": 3,
  "imageOutputQuality": 80,
  "inferenceStepCount": 30,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Conclusion
Ingolf's "Generate Image with Inpainting" action provides a powerful tool for developers and creatives alike, enabling the generation of stunning images with customizable parameters. Its versatility makes it suitable for a wide range of applications, from marketing to art creation, allowing for both speed and quality. 

To take your projects to the next level, start integrating this action into your workflows today and explore the endless possibilities of AI-driven image generation!