Create Stunning Illustrations with the stspanho/illusion Cognitive Actions

23 Apr 2025
Create Stunning Illustrations with the stspanho/illusion Cognitive Actions

In today's digital landscape, creating visually striking content is essential for engaging users and conveying messages effectively. The stspanho/illusion Cognitive Actions offer powerful tools for developers looking to enhance their applications with advanced image-processing capabilities. One key action within this suite is the ability to generate stunning SD illusions from drawings, complete with customizable depth effects. By leveraging these pre-built actions, developers can save time and effort while providing users with visually captivating experiences.

Prerequisites

Before you can start using the Cognitive Actions, you'll need to ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • A basic understanding of JSON and RESTful API concepts.
  • Familiarity with Python and the requests library for making API calls.

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

Cognitive Actions Overview

Create SD Illusion with Depth from Drawing

This action generates an SD illusion from a drawing by adding depth. It utilizes various model types such as ZoeD_N, ZoeD_K, and ZoeD_NK to create detailed illustrations with customizable guidance settings.

Input

To invoke this action, you need to provide an input JSON payload that adheres to the following schema:

  • prompt (required): A string that guides the generation process. Example: "concept art . digital artwork, illustrative, painterly, matte painting, highly detailed"
  • image: (optional) A URI of the input image. If omitted, a QR code will be generated automatically. Example: https://www.webxr.be/art/img/image664fbd5868a94.jpeg
  • width: (optional, default is 768) Specifies the width of the output image.
  • height: (optional, default is 768) Specifies the height of the output image.
  • numOutputs: (optional, default is 1) Sets the number of output images to generate (1 to 4).
  • seed: (optional, default is -1) A numerical seed for reproducible results.
  • guidanceScale: (optional, default is 7.5) Determines the scale for classifier-free guidance (0.1 to 30).
  • negativePrompt: (optional, default is "ugly, disfigured, low quality, blurry, nsfw") Terms to avoid in the generated image.
  • qrCodeContent: (optional) The content or URL that the QR code will link to.
  • qrCodeBackground: (optional, default is "gray") Background color of the QR code (choices: 'gray' or 'white').
  • border: (optional, default is 1) Defines the QR code border size (0 to 4).
  • numInferenceSteps: (optional, default is 40) Specifies the diffusion steps for the generation (0 to 100).
  • controlnetConditioningScale: (optional, default is 1) Adjusts outputs from the controlnet.

Example Input:

{
  "image": "https://www.webxr.be/art/img/image664fbd5868a94.jpeg",
  "border": 4,
  "prompt": "concept art . digital artwork, illustrative, painterly, matte painting, highly detailed",
  "guidanceScale": 7.5,
  "qrCodeContent": "",
  "negativePrompt": "ugly, disfigured, low quality, blurry, nsfw",
  "numInferenceSteps": 40,
  "controlnetConditioningScale": 1
}

Output

The action typically returns an array of URLs pointing to the generated images. For example:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/6675de5d-def4-4fc0-97b2-29802f9601fc/6f9831bd-edf3-4ed9-a745-286aa304d579.png",
  "https://assets.cognitiveactions.com/invocations/6675de5d-def4-4fc0-97b2-29802f9601fc/32c6f8d7-1d40-47a7-b2b2-8ebbb6e73c4c.png"
]

Conceptual Usage Example (Python)

Here's how you might call this 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 = "7251ff38-1485-4a56-a6ee-3bcc4fbb9890"  # Action ID for Create SD Illusion with Depth from Drawing

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://www.webxr.be/art/img/image664fbd5868a94.jpeg",
    "border": 4,
    "prompt": "concept art . digital artwork, illustrative, painterly, matte painting, highly detailed",
    "guidanceScale": 7.5,
    "qrCodeContent": "",
    "negativePrompt": "ugly, disfigured, low quality, blurry, nsfw",
    "numInferenceSteps": 40,
    "controlnetConditioningScale": 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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for the "Create SD Illusion with Depth from Drawing" action is specified, and the input payload is structured according to the action's requirements.

Conclusion

The stspanho/illusion Cognitive Actions provide developers with powerful tools to create visually stunning images, enhancing the user experience in various applications. By integrating the "Create SD Illusion with Depth from Drawing" action, developers can easily generate intricate visual content while maintaining control over the output. Explore these actions further to unlock more creative possibilities in your projects!