Create Stunning Images with the leonkmak/sdxl-xmas Cognitive Actions

In the rapidly evolving realm of AI-driven creativity, the leonmak/sdxl-xmas Cognitive Actions offer developers a powerful toolset for generating customized images. By leveraging advanced inpainting and img2img techniques, these actions enable you to create tailored visuals with a multitude of adjustable parameters. The pre-built actions streamline the process, making it easier to integrate complex image generation capabilities into your applications.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform, which will be required for authentication.
- Familiarity with making HTTP requests and handling JSON data.
To authenticate your requests, you will typically pass the API key in the headers of your HTTP calls.
Cognitive Actions Overview
Generate Customized Image
Description: This action allows you to create customized images using advanced inpainting and img2img techniques. You can adjust various parameters like prompt strength, image dimensions, and refining methods to enhance the output. Additionally, it supports negative prompts to exclude undesired content and applies watermarks for verification of image origin.
Category: Image Generation
Input
The input for this action consists of several fields, each with specific requirements:
- prompt (string): The main descriptive prompt for the image generation process.
Example:"person wearing santa costume holding a sign with the words \"looking for assistants\"" - width (integer): Width of the output image in pixels. Default is 1024.
Example:1024 - height (integer): Height of the output image in pixels. Default is 1024.
Example:1024 - refine (string): Selects the refine style to apply (options:
no_refiner,expert_ensemble_refiner,base_image_refiner). Default isno_refiner.
Example:"no_refiner" - loraScale (number): LoRA additive scale applicable to trained models (0 to 1).
Example:1 - scheduler (string): Sets the scheduler type used during the generation process. Default is
K_EULER.
Example:"K_EULER" - guidanceScale (number): Scale factor for classifier-free guidance (ranging from 1 to 50).
Example:7.5 - highNoiseFrac (number): Fraction of noise utilized when
expert_ensemble_refineris selected.
Example:0.73 - applyWatermark (boolean): Applies a watermark for image origin verification. Default is
true.
Example:true - negativePrompt (string): Avoids undesirable features in the generated image.
Example:""(empty string) - promptStrength (number): Defines prompt strength for
img2imgorinpaint.
Example:0.8 - numberOfOutputs (integer): Specifies the number of images to output (1 to 4).
Example:1 - numberOfInferenceSteps (integer): Number of denoising steps during generation (1 to 500).
Example:50
Here’s an example JSON payload for invoking the action:
{
"width": 1024,
"height": 1024,
"prompt": "person wearing santa costume holding a sign with the words \"looking for assistants\"",
"refine": "no_refiner",
"loraScale": 1,
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"highNoiseFrac": 0.73,
"applyWatermark": true,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"numberOfInferenceSteps": 50
}
Output
The action returns a list of generated image URLs. Here’s an example of what the output might look like:
[
"https://assets.cognitiveactions.com/invocations/9735f73b-adc8-4c49-9703-76cc591ba342/a1f01f39-a3d5-4535-aa61-e8359c025719.png"
]
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet demonstrating how to call 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 = "99b1b334-2a81-4b1e-8ced-0e37f68a6846" # Action ID for Generate Customized Image
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "person wearing santa costume holding a sign with the words \"looking for assistants\"",
"refine": "no_refiner",
"loraScale": 1,
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"highNoiseFrac": 0.73,
"applyWatermark": True,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"numberOfInferenceSteps": 50
}
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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the "Generate Customized Image" action, and the payload object contains the necessary parameters for the request.
Conclusion
The leonmak/sdxl-xmas Cognitive Actions provide a robust framework for developers looking to integrate advanced image generation capabilities into their applications. By utilizing the "Generate Customized Image" action, you can easily create visually stunning content tailored to your needs. Whether you're developing creative applications or enhancing existing workflows, these actions can significantly boost your productivity and creativity. Start experimenting with these powerful tools to unlock new possibilities!