Generate Stunning Images with the yunael16/mia2024 Cognitive Actions

21 Apr 2025
Generate Stunning Images with the yunael16/mia2024 Cognitive Actions

In the realm of artificial intelligence, image generation has become a pivotal area of innovation. The yunael16/mia2024 Cognitive Actions provide developers with powerful tools to create and manipulate images using advanced techniques like inpainting and image-to-image transformations. With pre-built actions, developers can easily integrate these capabilities into their applications, enhancing user experiences and enabling creative expression.

Prerequisites

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

  • An API key for the Cognitive Actions platform, which will be used to authenticate your requests.
  • A basic understanding of JSON format, as the input and output structures will be in this format.

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

Cognitive Actions Overview

Generate Image with Inpainting

This action allows for the generation of images through image-to-image transformation or inpainting techniques. You can utilize either the 'dev' model for optimal quality with 28 steps or the 'schnell' model for faster results with only 4 steps. Various parameters such as image aspect ratio, dimensions, and output quality can be controlled to achieve the desired result.

Input

The input for this action is structured as follows:

{
  "prompt": "A detailed description of the image you want to generate.",
  "model": "dev",
  "guidanceScale": 3.5,
  "mainLoraScale": 1,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "imageAspectRatio": "9:16",
  "imageOutputFormat": "png",
  "imageOutputQuality": 100,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Example input:

{
  "model": "dev",
  "prompt": "\"Onboard an X-Wing spacecraft, a Siberian husky TOK with black and white fur and striking blue eyes named Mia sits in the co-pilot seat behind the pilot’s chair in a futuristic, minimalist cockpit. The vastness of outer space is visible through the window, with stars and a distant planet in the background. Mia has a focused expression, with her paws on the control dashboard as if ready to take command. Blue lighting and reflections from the control panels create an epic, heroic atmosphere. Cinematic style, 9:16, 4K resolution.\"",
  "guidanceScale": 3.5,
  "mainLoraScale": 1,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "imageAspectRatio": "9:16",
  "imageOutputFormat": "png",
  "imageOutputQuality": 100,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Output

The output typically returns a URL to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/0b013986-6366-4d35-b064-61f428bf1f58/9e574e63-0ac9-4946-b8e4-dca007724778.png"
]

Conceptual Usage Example (Python)

Here's how you might structure a Python request to invoke this action:

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 = "611ee929-6e13-4aa4-b81b-62856bd10a5b"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "\"Onboard an X-Wing spacecraft, a Siberian husky TOK with black and white fur and striking blue eyes named Mia sits in the co-pilot seat behind the pilot’s chair in a futuristic, minimalist cockpit. The vastness of outer space is visible through the window, with stars and a distant planet in the background. Mia has a focused expression, with her paws on the control dashboard as if ready to take command. Blue lighting and reflections from the control panels create an epic, heroic atmosphere. Cinematic style, 9:16, 4K resolution.\"",
    "guidanceScale": 3.5,
    "mainLoraScale": 1,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "imageAspectRatio": "9:16",
    "imageOutputFormat": "png",
    "imageOutputQuality": 100,
    "additionalLoraScale": 1,
    "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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and adjust the endpoint URL as needed. The input payload is structured according to the action's requirements.

Conclusion

The yunael16/mia2024 Cognitive Action for generating images with inpainting opens up exciting possibilities for developers looking to enhance their applications with advanced image generation capabilities. By leveraging this action, you can create unique visual content, offering users a more engaging experience.

Next, consider experimenting with different prompts and parameters to see how you can push the boundaries of creativity in your applications!