Generate Stunning Images with Inpainting Using Amadutownadvisory Cognitive Actions

22 Apr 2025
Generate Stunning Images with Inpainting Using Amadutownadvisory Cognitive Actions

In today’s digital landscape, the need for custom images is paramount, whether for marketing, product showcases, or creative projects. The Amadutownadvisory/vambahsillahlora Cognitive Actions provide developers with a powerful toolset for generating images using advanced inpainting techniques. These pre-built actions enable seamless integration into applications, allowing for quick and efficient image creation tailored to specific needs.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Familiarity with JSON formatting, as you'll be working with JSON payloads for input and output.
  • Basic knowledge of making API calls, particularly using Python or similar languages.

Authentication typically involves passing your API key in the HTTP headers when making requests.

Cognitive Actions Overview

Generate Image with Inpainting

Description:
This action allows you to create a custom image using inpainting techniques. You can specify a URI for mask and image inputs, adjust the image resolution, and utilize a fast mode for quicker predictions. With options for guidance scales and LoRA weights, this action is optimized for generating images quickly and consistently.

Category: Image Generation

Input

The input schema for this action requires a JSON object with the following properties:

  • prompt (required): Text prompt for image generation. Example: "VAMBAH_SILLAH in a modern office with the Boston skyline behind him in a tailored gray suit looking directly ahead with a shocked expression holding a Google Pixel phone with the phone screen facing outwards."
  • mask (optional): URI of the image mask used for inpainting.
  • image (optional): URI of the input image for image-to-image or inpainting mode.
  • width (optional): Width of the generated image (must be a multiple of 16).
  • height (optional): Height of the generated image (must be a multiple of 16).
  • goFast (optional): Boolean to enable faster predictions.
  • loraScale (optional): Adjusts the intensity of the main LoRA application.
  • modelType (optional): Selects the model type for inference (either "dev" or "schnell").
  • megapixels (optional): Specifies the approximate number of megapixels for the generated image.
  • numOutputs (optional): Number of output images to generate (max: 4).
  • aspectRatio (optional): Determines the aspect ratio of the image.
  • outputFormat (optional): Specifies the format for the output images (WEBP, JPG, PNG).
  • guidanceScale (optional): Sets the guidance scale in the diffusion process.
  • outputQuality (optional): Defines the quality of the saved output images.
  • promptStrength (optional): Controls the strength of the prompt in img2img processing.

Example Input:

{
  "width": 1440,
  "goFast": false,
  "height": 1440,
  "prompt": "VAMBAH_SILLAH in a modern office with the boston skyline behind him in a tailored gray suit looking directly ahead with a shocked expression holding a google pixel phone with the phone screen facing outwards",
  "loraScale": 1,
  "modelType": "dev",
  "megapixels": "1",
  "numOutputs": 1,
  "aspectRatio": "16:9",
  "outputFormat": "jpg",
  "guidanceScale": 3,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "numInferenceSteps": 28
}

Output

The action typically returns a URL pointing to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/d7086a35-5fa5-4d1c-b493-901b239f597e/2a40098b-ca9a-4044-8188-b8c463627a10.jpg"
]

Conceptual Usage Example (Python)

Here’s how you can 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 = "19c6b08e-c60d-4437-8fe6-b09c8def7b9b" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "width": 1440,
    "goFast": False,
    "height": 1440,
    "prompt": "VAMBAH_SILLAH in a modern office with the boston skyline behind him in a tailored gray suit looking directly ahead with a shocked expression holding a google pixel phone with the phone screen facing outwards",
    "loraScale": 1,
    "modelType": "dev",
    "megapixels": "1",
    "numOutputs": 1,
    "aspectRatio": "16:9",
    "outputFormat": "jpg",
    "guidanceScale": 3,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "numInferenceSteps": 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}
    )
    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 is set for the Generate Image with Inpainting action. The input payload is structured based on the action's requirements, and the request is sent to the hypothetical endpoint. The response is processed to extract the generated image URL.

Conclusion

The Amadutownadvisory/vambahsillahlora Cognitive Actions provide a robust solution for developers looking to integrate custom image generation into their applications. With features like inpainting, adjustable parameters, and various output formats, these actions open up a world of possibilities for creative projects. Start exploring and harness the power of image generation today!