Generate Stunning Artistic Images with the SDXL Gouache Cognitive Actions

The SDXL Gouache Cognitive Actions provide developers with powerful tools to generate artistic images based on customizable prompts and styles. These pre-built actions simplify the image creation process, allowing you to focus on creativity while leveraging advanced machine learning techniques. With options for img2img and inpaint modes, you can refine existing images or create entirely new ones from scratch.
Prerequisites
Before diving into the Cognitive Actions, you'll need to ensure you have the following:
- API Key: Obtain your API key from the Cognitive Actions platform to authenticate your requests.
- Basic Setup: Familiarity with making HTTP requests and handling JSON data in your preferred programming language.
Authentication typically involves including your API key in the request headers when making calls to the Cognitive Actions endpoint.
Cognitive Actions Overview
Generate Artistic Image
The Generate Artistic Image action allows you to create artistic images based on user-defined prompts and styles. It supports various configurations, including image dimensions, refinement styles, and safety features.
Input
The input for this action is structured as a JSON object with the following fields:
- mask (optional): URI for an input mask used in inpaint mode.
- seed (optional): Random seed for the image generation.
- image (optional): URI for the input image in img2img or inpaint mode.
- width (default: 1024): Width of the output image in pixels.
- height (default: 1024): Height of the output image in pixels.
- prompt (default: "An astronaut riding a rainbow unicorn"): Text prompt that guides the image generation.
- refine (default: "no_refiner"): Selects the refinement style for the image generation.
- loraScale (default: 0.6): Additive scale for LoRA (Low-Rank Adaptation).
- scheduler (default: "K_EULER"): Algorithm for image generation.
- loraWeights (optional): URI for the LoRA weights to apply.
- refineSteps (optional): Number of steps for refinement.
- guidanceScale (default: 7.5): Scale for classifier-free guidance.
- applyWatermark (default: true): Indicates if a watermark should be applied.
- negativePrompt (optional): Negative prompt to exclude certain elements.
- promptStrength (default: 0.8): Strength of the prompt when using img2img/inpaint.
- numberOfOutputs (default: 1): Number of images to generate (1 to 4).
- highNoiseFraction (default: 0.8): Fraction of noise for refinement.
- disableSafetyChecker (default: false): Option to disable the safety checker.
- numberOfInferenceSteps (default: 50): Number of denoising steps.
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "In the style of TOK, a Canadian flag blowing in the wind",
"refine": "no_refiner",
"loraScale": 0.7,
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"applyWatermark": true,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8,
"numberOfInferenceSteps": 50
}
Output
The output of the action typically returns a JSON array containing URLs to the generated images.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/39e256c2-975d-4d4a-a678-1bd71e2cf5cd/beecd468-4310-42d3-b003-665481cda660.png"
]
Conceptual Usage Example (Python)
Here's how you might call the Generate Artistic Image action using Python. This code snippet demonstrates how to structure your request:
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 = "56c24351-20b5-43d5-86a9-fc9350d76a73" # Action ID for Generate Artistic Image
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "In the style of TOK, a Canadian flag blowing in the wind",
"refine": "no_refiner",
"loraScale": 0.7,
"scheduler": "K_EULER",
"guidanceScale": 7.5,
"applyWatermark": True,
"negativePrompt": "",
"promptStrength": 0.8,
"numberOfOutputs": 1,
"highNoiseFraction": 0.8,
"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, replace the placeholder for your API key and ensure the endpoint is correct. The action ID and input payload structure are essential for a successful request.
Conclusion
The SDXL Gouache Cognitive Actions empower developers to create stunning artistic images with just a few lines of code. Whether you're looking to generate unique artwork or refine existing images, these actions provide the flexibility and capabilities you need. Start exploring the possibilities today, and imagine what you can create!