Create Stunning Images with Angela's Inpainting Action

26 Apr 2025
Create Stunning Images with Angela's Inpainting Action

Creating visually appealing images has never been easier, thanks to Angela's powerful Cognitive Actions. Among these, the "Generate Image with Inpainting" action stands out by allowing developers to create detailed images with enhanced capabilities. This action not only streamlines the image generation process but also offers customization options that cater to specific project needs.

The benefits of using Angela's inpainting feature include the ability to generate high-quality images tailored to your specifications, whether for marketing materials, art projects, or social media content. Imagine needing a unique image for a campaign; with Angela, you can generate exactly what you envision in a matter of moments. With support for customizable settings, developers can ensure their outputs meet the desired dimensions and quality, making it a versatile tool for various use cases.

Prerequisites

Before diving into the action, ensure you have an API key for Angela's Cognitive Actions and a basic understanding of how to make API calls.

Generate Image with Inpainting

The "Generate Image with Inpainting" action allows you to create detailed images by utilizing inpainting mode, which enhances the replication capabilities of your images while accommodating specific dimensions. This action supports a range of customizable settings, enabling you to adjust aspects such as the image mask, aspect ratio, and output quality, thereby tailoring the final product to your requirements.

Input Requirements:
To successfully invoke this action, provide a structured JSON object that includes the following key components:

  • prompt: A detailed text description of the image you want to create.
  • mask: (Optional) A URI pointing to an image mask, which will take precedence over dimension settings.
  • image: (Optional) A URI for the input image if you are using image-to-image or inpainting mode.
  • width & height: (Optional) Specify the dimensions of the generated image, effective when using a custom aspect ratio.
  • numOutputs: The number of images you want to generate.
  • outputQuality: Set the quality of the generated images ranging from 0 to 100.
  • Additional parameters for fine-tuning include guidanceScale, inferenceModel, extraLora, and more.

Expected Output:
Upon successful execution, the action returns an array of image URLs, each pointing to a generated image based on your specifications.

Use Cases for this specific action:

  • Marketing and Advertising: Generate eye-catching visuals for campaigns or promotional materials tailored to your brand’s identity.
  • Art and Design Projects: Artists can leverage this action to create unique artworks based on their prompts, merging creativity with technology.
  • Social Media Content: Quickly produce high-quality images for posts, ensuring a consistent and engaging aesthetic across platforms.
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 = "cacf7fbe-f9ad-4426-b8b4-82d6958974dd" # 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": "Close up shot of ANGELA wearing a white tank top with blood on it, holding a wooden bat, standing in front of an old timey storefront with wood siding and gas pumpts, blurred background, highly detailed, 8k, IMG_420.HEIC, photorealistic",
  "loraScale": 1,
  "numOutputs": 4,
  "guidanceScale": 2.5,
  "outputQuality": 100,
  "extraLoraScale": 1,
  "inferenceModel": "schnell",
  "promptStrength": 0.8,
  "imageAspectRatio": "16:9",
  "imageOutputFormat": "png",
  "numInferenceSteps": 50
}

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

Angela's "Generate Image with Inpainting" action opens up a world of possibilities for developers looking to create stunning images effortlessly. With its customizable features and ability to generate high-quality visuals quickly, it serves as an invaluable tool for various applications, from marketing to art creation. To get started, simply integrate this action into your projects and watch your creative visions come to life!