Create Stunning Images with the xiankgx/sdxl-evolution-0.1 Cognitive Actions

24 Apr 2025
Create Stunning Images with the xiankgx/sdxl-evolution-0.1 Cognitive Actions

In the realm of image generation, the xiankgx/sdxl-evolution-0.1 API offers a powerful toolset known as Cognitive Actions, designed to leverage advanced algorithms for creating unique and customized images. Specifically, the "Perform Genetic Image Synthesis" action allows developers to harness the capabilities of Stable Diffusion XL (SDXL) models, enabling them to combine and evolve images creatively. This article will guide you through this action, detailing its inputs, outputs, and providing a conceptual usage example.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.

Authentication typically involves passing the API key in the headers of your requests, allowing secure communication with the Cognitive Actions service.

Cognitive Actions Overview

Perform Genetic Image Synthesis

The Perform Genetic Image Synthesis action utilizes a genetic algorithm to combine and evolve Stable Diffusion XL models, resulting in highly-customized images with enhanced details and guidance. This action is categorized under image-generation.

Input

The input for this action requires a JSON object that adheres to the following schema:

  • prompt (string, required): A textual description that guides the content of the generated image.
  • seed (integer, optional): The seed number for reproducibility (default is -1 for a random seed). Valid range is -1 to 2147483647.
  • steps (integer, optional): The number of denoising steps (default is 8). Valid range is 1 to 100.
  • width (integer, optional): The width of the generated images in pixels. Choose from predefined values (default is 1024).
  • height (integer, optional): The height of the generated images in pixels. Choose from predefined values (default is 1024).
  • guidanceScale (number, optional): Determines the level of classifier-free guidance (default is 2). Valid range is 0 to 30.
  • negativePrompt (string, optional): A description specifying elements to exclude from the generated image.
  • numberOfSamples (integer, optional): The number of image samples to generate (default is 1). Valid range is 1 to 3.

Example Input:

{
  "seed": -1,
  "steps": 8,
  "width": 1152,
  "height": 832,
  "prompt": "dog in shining knight armor",
  "guidanceScale": 2,
  "negativePrompt": "",
  "numberOfSamples": 1
}

Output

The output of this action consists of an array of URLs pointing to the generated images. In case of successful execution, you can expect a response like this:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/2d12acc5-2f33-4c40-9192-1471fbe6a8f2/78802a6b-b428-468f-a593-417befd44dc1.jpg"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to call the Cognitive Actions execution endpoint for the Perform Genetic Image Synthesis action. Be sure to replace the placeholder values with your own API key and endpoint.

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 = "bfed8171-3cd0-42f5-9a8c-958e6f5770e5"  # Action ID for Perform Genetic Image Synthesis

# Construct the input payload based on the action's requirements
payload = {
    "seed": -1,
    "steps": 8,
    "width": 1152,
    "height": 832,
    "prompt": "dog in shining knight armor",
    "guidanceScale": 2,
    "negativePrompt": "",
    "numberOfSamples": 1
}

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, the action_id corresponds to the Perform Genetic Image Synthesis action. The input payload is structured according to the action's requirements, allowing for effective communication with the Cognitive Actions service.

Conclusion

The xiankgx/sdxl-evolution-0.1 Cognitive Actions, particularly the Perform Genetic Image Synthesis action, empower developers to create stunning, customized images through advanced algorithms. By understanding the input schema and output structure, you can seamlessly integrate this functionality into your applications. Explore various creative prompts and parameters to unlock the full potential of image generation in your projects!