Create Stunning Mandala Coloring Pages with Cognitive Actions for SDXL

Introduction
In the world of digital creativity, the codingdudecom/sdxl-mandala API brings to the forefront a powerful tool for generating intricate mandala designs. The Cognitive Actions provided under this spec enable developers to easily create stunning coloring pages that cater to artists, educators, and individuals seeking mindfulness activities. By leveraging pre-built actions, you can save time and effort while delivering beautiful, customized content.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform.
- Setup: Familiarize yourself with the basic setup for making API calls, which typically involves including the API key in the request headers.
Conceptually, authentication could look like this:
headers = {
"Authorization": f"Bearer YOUR_COGNITIVE_ACTIONS_API_KEY",
"Content-Type": "application/json"
}
Cognitive Actions Overview
Generate Mandala Coloring Pages
This action allows you to create intricate round mandalas and coloring book designs using the fine-tuned SDXL model. It is ideal for artists, educators, and anyone looking to engage in mindfulness activities through art.
- Category: image-generation
Input
The input for this action is structured as follows:
| Field | Type | Description |
|---|---|---|
| mask | string | URI for input mask in inpaint mode. Black areas remain unchanged, while white areas are inpainted. |
| seed | integer | Random seed used for generating variations. Leave blank for random seeding. |
| image | string | URI for input image in img2img or inpaint mode. |
| width | integer | Width in pixels of the output image. Default is 1024. |
| height | integer | Height in pixels of the output image. Default is 1024. |
| prompt | string | Text prompt to guide the output image generation. Default is 'An astronaut riding a rainbow unicorn.' |
| loraScale | number | LoRA additive scale. Only applicable on trained models. |
| loraWeights | string | LoRA weights to apply during image generation. Leave blank to use default weights. |
| refineSteps | integer | Number of refinement steps when using base_image_refiner. |
| refineStyle | string | Select the style for refinement (e.g., no_refiner, expert_ensemble_refiner). |
| guidanceScale | number | Scale factor for classifier-free guidance. Range is 1 to 50. |
| applyWatermark | boolean | Toggle to apply a watermark for identifying generated images. Default is true. |
| negativePrompt | string | A text prompt to discourage specific content in the output image. |
| promptStrength | number | Controls prompt influence strength for img2img/inpaint modes. |
| outputImageCount | integer | Specify the number of images to generate. Maximum is 4. |
| schedulingMethod | string | Choose a scheduling algorithm for the denoising process. |
| highNoiseFraction | number | Defines the noise fraction for expert_ensemble_refiner. |
| inferenceStepCount | integer | The number of steps to perform during denoising. |
| disableSafetyChecker | boolean | Option to disable the safety checker for generated images. |
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "a flower TOK mandal design, coloring pages for kids, illustration, white background",
"loraScale": 0.6,
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"applyWatermark": false,
"negativePrompt": "",
"promptStrength": 0.8,
"outputImageCount": 1,
"schedulingMethod": "K_EULER",
"highNoiseFraction": 0.8,
"inferenceStepCount": 30
}
Output
Upon successful execution, this action typically returns a link to the generated image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/14de8879-bfbe-4538-a125-73db1a78e02c/9a291f65-5c6c-40d8-aa8c-f0184080f68f.png"
]
Conceptual Usage Example (Python)
Here’s how you might construct a call to the Cognitive Actions execution endpoint 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 = "4f47b925-fc41-47ad-ac23-0c341ae02a35" # Action ID for Generate Mandala Coloring Pages
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "a flower TOK mandal design, coloring pages for kids, illustration, white background",
"loraScale": 0.6,
"refineStyle": "no_refiner",
"guidanceScale": 7.5,
"applyWatermark": False,
"negativePrompt": "",
"promptStrength": 0.8,
"outputImageCount": 1,
"schedulingMethod": "K_EULER",
"highNoiseFraction": 0.8,
"inferenceStepCount": 30
}
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 the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is constructed according to the action's input requirements, and the action ID is specified for generating the mandala coloring pages. The endpoint and request structure are illustrative, focusing on how to structure the input JSON.
Conclusion
The codingdudecom/sdxl-mandala Cognitive Actions provide a seamless way to create beautiful mandala designs for various purposes. By integrating these actions into your applications, you can enhance user engagement through personalized and artistic content. Explore the possibilities of creativity and mindfulness with these powerful tools, and consider experimenting with different prompts and settings to discover unique designs. Happy coding!