Enhance Your Applications with Image Generation using camiaguado/ilustraciones-incapto Actions

21 Apr 2025
Enhance Your Applications with Image Generation using camiaguado/ilustraciones-incapto Actions

In the ever-evolving landscape of digital art and image manipulation, the camiaguado/ilustraciones-incapto API offers powerful Cognitive Actions that enable developers to generate stunning images with precision and customization. One of the standout capabilities is the Generate Inpainted Image action, which leverages advanced techniques to manipulate and create images based on user-defined parameters. This article will delve into the capabilities of this action, outlining its inputs, outputs, and providing a conceptual guide to integrating it into your applications.

Prerequisites

To make use of the Cognitive Actions provided by the camiaguado/ilustraciones-incapto API, you will need to ensure that:

  • You have a valid API key for the Cognitive Actions platform.
  • You are familiar with making HTTP requests in your programming environment (e.g., Python).
  • You understand how to send JSON payloads in API requests.

Authentication typically involves passing your API key in the request headers, allowing you to securely access the available actions.

Cognitive Actions Overview

Generate Inpainted Image

The Generate Inpainted Image action is designed to create images based on an input mask and a variety of parameters. This action allows for detailed customization of the output, including the image size, refinement options, and even watermark application.

Input

The action requires a structured input defined by the following schema:

  • mask (string, required): URI of the input mask for inpainting mode. Black areas will remain unchanged, while white areas will be inpainted.
  • seed (integer, optional): Random seed for generating images. Leave blank for a random seed value.
  • image (string, required): URI of the input image for img2img or inpainting mode.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Text prompt to guide image generation.
  • refine (string, default: "no_refiner"): Defines the type of refinement to apply to the image.
  • loraScale (number, default: 0.6): LoRA additive scale.
  • scheduler (string, default: "K_EULER"): Selects the scheduling algorithm for image generation.
  • numOutputs (integer, default: 1): Number of images to output.
  • loraWeights (string, optional): URI of LoRA weights to apply.
  • refineSteps (integer, optional): Specifies the number of refinement steps.
  • guidanceScale (number, default: 7.5): Scale for classifier-free guidance.
  • highNoiseFrac (number, default: 0.8): For expert ensemble refiner, fraction of noise to use.
  • applyWatermark (boolean, default: true): Add a watermark to generated images.
  • negativePrompt (string, optional): Negative text prompt to prioritize against.
  • promptStrength (number, default: 0.8): Defines the influence of the image prompt.
  • numInferenceSteps (integer, default: 50): Total number of denoising steps.
  • disableSafetyChecker (boolean, default: false): Option to disable the safety checker.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "woman with long hair holding a cup of coffee",
  "refine": "expert_ensemble_refiner",
  "loraScale": 0.75,
  "scheduler": "K_EULER",
  "numOutputs": 1,
  "guidanceScale": 7.5,
  "highNoiseFrac": 0.8,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 1,
  "numInferenceSteps": 50
}

Output

The action returns a URL to the generated image, typically in the following format:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/50ee8e43-bed0-46a4-848d-eaa4f349ffb7/d67d8c4c-368a-4e1e-89df-6bed5f064c6b.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual implementation of 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 = "0921d6bc-7fd4-4276-91e3-736ebcc95747"  # Action ID for Generate Inpainted Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "woman with long hair holding a cup of coffee",
    "refine": "expert_ensemble_refiner",
    "loraScale": 0.75,
    "scheduler": "K_EULER",
    "numOutputs": 1,
    "guidanceScale": 7.5,
    "highNoiseFrac": 0.8,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 1,
    "numInferenceSteps": 50
}

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 example:

  • Replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key.
  • The action_id corresponds to the Generate Inpainted Image action.
  • The payload is constructed according to the required schema, ensuring proper formatting and inclusion of necessary parameters.

Conclusion

The Generate Inpainted Image action from the camiaguado/ilustraciones-incapto API provides a powerful tool for developers looking to integrate advanced image generation capabilities into their applications. By leveraging customizable parameters, you can create unique and tailored images that meet your specific needs. As you explore the possibilities of this action, consider how it can enhance user experiences in your projects and the creative opportunities it presents. Happy coding!