Transform Your Images with the Generate Inpainted Image Action from AniWis Lora

22 Apr 2025
Transform Your Images with the Generate Inpainted Image Action from AniWis Lora

In the rapidly evolving field of image processing, the ability to generate and modify images through prompts and parameters has become increasingly valuable. The robvandam12/aniwis-lora Cognitive Actions provide a robust solution for developers looking to integrate advanced image generation capabilities into their applications. One standout action within this spec is the Generate Inpainted Image action, which allows for image-to-image transformations while supporting various customization options.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Familiarity with making HTTP requests and handling JSON payloads.

Authentication generally involves including your API key in the headers of your requests, ensuring secure access to the Cognitive Actions API.

Cognitive Actions Overview

Generate Inpainted Image

The Generate Inpainted Image action is designed to create and modify images based on user-defined prompts and parameters. It supports various image processing techniques, including customizable aspect ratios, width, height, and model optimizations for speed and quality.

Input

The input schema requires the following fields:

  • prompt (required): A text prompt that describes the desired image.

Optional fields include:

  • mask: An image mask for inpainting mode.
  • seed: A random seed for reproducibility.
  • image: An input image for transformation.
  • width: Custom width for the generated image (when aspect ratio is 'custom').
  • height: Custom height for the generated image (when aspect ratio is 'custom').
  • loraScale: Intensity of the main LoRA application.
  • imageFormat: Desired format for output images (e.g., webp, jpg, png).
  • imageQuality: Quality setting for the output image.
  • denoisingSteps: Number of steps for denoising.
  • inferenceModel: Model selection for inference.
  • numberOfOutputs: Total outputs to generate per request.
  • imageAspectRatio: Aspect ratio for the generated image.
  • optimizeForSpeed: Enable speed optimizations.
  • ignoreSafetyChecks: Disable safety checks.
  • additionalLoraScale: Strength of additional LoRA application.
  • imagePromptStrength: Degree of prompt influence in img2img processing.
  • diffusionGuidanceScale: Scale for diffusion guidance.

Example Input:

{
  "prompt": "A stunning model named Anita standing in a luxurious, elegant apartment with modern, sophisticated decor. She is wearing a gorgeous, flowing evening gown that complements her long, glossy hair. Anita has a flawless, striking face with soft, refined features. The scene is warm and softly lit, with tasteful furniture, art, and details that emphasize the apartment's luxury and sophistication. The overall ambiance is elegant and stylish.",
  "loraScale": 1,
  "imageFormat": "webp",
  "imageQuality": 90,
  "denoisingSteps": 28,
  "inferenceModel": "dev",
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8,
  "diffusionGuidanceScale": 3.5
}

Output

The action typically returns a URL to the generated image in the specified format.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/989700c8-e30c-4bc5-877a-848d408bc772/08971381-2b34-4a27-aa83-df26666586dd.webp"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Inpainted Image 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 = "e463904c-aec5-48d2-99d1-1973c220b6e1"  # Action ID for Generate Inpainted Image

# Construct the input payload based on the action's requirements
payload = {
  "prompt": "A stunning model named Anita standing in a luxurious, elegant apartment with modern, sophisticated decor...",
  "loraScale": 1,
  "imageFormat": "webp",
  "imageQuality": 90,
  "denoisingSteps": 28,
  "inferenceModel": "dev",
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8,
  "diffusionGuidanceScale": 3.5
}

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, you need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and the input payload are structured according to the requirements outlined for the Generate Inpainted Image action.

Conclusion

The Generate Inpainted Image action from the robvandam12/aniwis-lora spec offers a powerful way to create and modify images using prompts and advanced parameters. By integrating this action into your applications, you can unleash a new level of creativity and functionality. Consider exploring additional use cases, such as generating art for games, enhancing photos, or creating unique marketing materials. The possibilities are endless!