Elevate Your Image Processing with the mr-juancho/minilionieto23 Cognitive Actions

24 Apr 2025
Elevate Your Image Processing with the mr-juancho/minilionieto23 Cognitive Actions

In today's rapidly evolving digital landscape, the ability to generate and manipulate images using advanced techniques is a game changer for developers. The mr-juancho/minilionieto23 API offers a powerful Cognitive Action that allows you to create stunning images through the innovative process of inpainting. With customizable settings for aspect ratios, dimensions, and various models, this action enhances your applications and expands your creative possibilities.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON and how to make API calls.

To authenticate your requests, you will typically pass your API key in the headers of your HTTP requests.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action allows you to create transformed images using an image-to-image technique, supporting various settings for inpainting, including aspect ratio, width, and height. This action is categorized under image-processing and provides both fast and detailed prediction modes using either the 'dev' or 'schnell' models.

Input

The input for this action requires a prompt and can include several optional fields, allowing for extensive customization.

Here’s a breakdown of the required and optional fields based on the input schema:

  • Required:
    • prompt: A detailed description of the desired image.
  • Optional:
    • mask: URI of the image mask for inpainting.
    • seed: Random seed for consistent results.
    • image: URI of the input image.
    • model: Select between 'dev' (default) or 'schnell'.
    • width: Custom width of the image.
    • height: Custom height of the image.
    • goFast: Boolean to enable faster processing.
    • imageAspectRatio: Specify the aspect ratio.
    • imageOutputFormat: Desired output format (webp, jpg, png).
    • imageOutputQuality: Output quality percentage.
    • numberOfOutputs: Number of images to generate.

Example Input:

{
  "model": "dev",
  "width": 810,
  "goFast": false,
  "prompt": "A hyper-realistic scene of Lionel Messi in a locker room, mid-motion as he puts on his Argentina jersey with calm focus. In front of him stands 'minilionieto23,' a small 3-year-old boy also wearing an Argentina jersey. The child’s face is fully visible, showing wide-eyed wonder and an innocent smile as he watches Messi closely. The locker room is detailed with jerseys, cleats, and warm ambient lighting, emphasizing the emotional bond and realism of the moment.",
  "loraScale": 1,
  "megapixels": "1",
  "guidanceScale": 3,
  "extraLoraScale": 1,
  "numberOfOutputs": 1,
  "imageAspectRatio": "9:16",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 99,
  "imagePromptStrength": 0.8,
  "numberOfInferenceSteps": 28
}

Output

The output of this action typically returns a URL to the generated image. For instance:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/7550f510-af9b-4cee-8f3c-4b6b160f0702/af6da97d-725c-40a8-926a-bd257745c9dd.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual example of how you might 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 = "f75dfa46-c0d4-4700-8d6f-cf53899c0c6f"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 810,
    "goFast": False,
    "prompt": "A hyper-realistic scene of Lionel Messi in a locker room, mid-motion as he puts on his Argentina jersey with calm focus. In front of him stands 'minilionieto23,' a small 3-year-old boy also wearing an Argentina jersey. The child’s face is fully visible, showing wide-eyed wonder and an innocent smile as he watches Messi closely. The locker room is detailed with jerseys, cleats, and warm ambient lighting, emphasizing the emotional bond and realism of the moment.",
    "loraScale": 1,
    "megapixels": "1",
    "guidanceScale": 3,
    "extraLoraScale": 1,
    "numberOfOutputs": 1,
    "imageAspectRatio": "9:16",
    "imageOutputFormat": "webp",
    "imageOutputQuality": 99,
    "imagePromptStrength": 0.8,
    "numberOfInferenceSteps": 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}  # 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 replace the placeholder for your API key and endpoint with actual values. The action_id corresponds to the Generate Image with Inpainting action. The payload is structured according to the input schema, ensuring that all necessary fields are included.

Conclusion

The Generate Image with Inpainting Cognitive Action from the mr-juancho/minilionieto23 API opens up a world of possibilities for image processing in your applications. By leveraging its robust features, you can create stunning visual outputs tailored to your specifications. Start integrating this action today and explore the creative potential it brings to your projects!