Enhance Your Artwork with the jbilcke/sdxl-brussels Cognitive Actions

In today's digital landscape, generating and manipulating images using AI has become increasingly accessible. The jbilcke/sdxl-brussels API provides a powerful set of Cognitive Actions designed to facilitate image generation tasks, particularly through inpainting techniques. With these pre-built actions, developers can create visually stunning outputs guided by custom text prompts, offering a range of enhancements for image quality and processing flexibility.
Prerequisites
Before diving into the Cognitive Actions, ensure you have the following prerequisites:
- API Key: You will need an API key to access the Cognitive Actions platform. This key should be passed in the headers of your requests for authentication.
- Environment Setup: Make sure you have a programming environment ready to execute HTTP requests, such as Python with the
requestslibrary.
Cognitive Actions Overview
Generate Inpainted Image
The Generate Inpainted Image action allows you to create an inpainted image based on a specified text prompt. It provides options for image customization, including size, refinement methods, and scheduling algorithms, to enhance the quality of the generated output.
Input
The action requires the following input parameters:
- mask (URI): The mask used in inpaint mode, indicating which areas to preserve (black) and which to inpaint (white).
- seed (integer): A random seed for reproducibility; leave blank for randomization.
- image (URI): The input image for img2img or inpaint processing.
- width (integer): Width of the output image in pixels (default: 1024).
- height (integer): Height of the output image in pixels (default: 1024).
- prompt (string): Text prompt describing the desired output image (default: "An astronaut riding a rainbow unicorn").
- refine (string): Refinement method to enhance the image (options: "no_refiner", "expert_ensemble_refiner", "base_image_refiner").
- loraScale (number): Scale factor for LoRA adjustments (range: 0 to 1, default: 0.6).
- scheduler (string): Scheduling algorithm (default: "K_EULER").
- guidanceScaling (number): Influences adherence to the prompt (range: 1 to 50, default: 7.5).
- numberOfOutputs (integer): Total number of images to generate (range: 1 to 4, default: 1).
- promptIntensity (number): Intensity of the prompt when using img2img or inpaint (range: 0 to 1, default: 0.8).
- refinementSteps (integer): Count of refinement iterations for "base_image_refiner".
- applyWatermarking (boolean): Enable/disable watermarking on generated images (default: true).
- highNoiseFraction (number): Fraction of noise for "expert_ensemble_refiner" (range: 0 to 1, default: 0.8).
- negativePrompting (string): Text prompt specifying what to avoid in the output image.
- inferenceStepCount (integer): Number of steps in the noise reduction process (range: 1 to 500, default: 50).
Example Input
{
"width": 1024,
"height": 1024,
"prompt": "intricate details, beautiful, zeppelin flying over canyon, in the style of TOK",
"refine": "no_refiner",
"loraScale": 0.81,
"scheduler": "K_EULER",
"guidanceScaling": 18.6,
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"applyWatermarking": true,
"highNoiseFraction": 0.8,
"inferenceStepCount": 50
}
Output
The action typically returns an array containing the URLs of the generated images based on the input provided. For example:
[
"https://assets.cognitiveactions.com/invocations/fb7d21b7-6c55-4217-a8e7-a24d381aba44/56c1832e-7713-4dcb-ab5c-0cca90c34039.png"
]
Conceptual Usage Example (Python)
Here’s how you might structure a request to execute the Generate Inpainted Image 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 = "5a57d8fe-3275-43d7-8ab2-c3e95028995b" # Action ID for Generate Inpainted Image
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "intricate details, beautiful, zeppelin flying over canyon, in the style of TOK",
"refine": "no_refiner",
"loraScale": 0.81,
"scheduler": "K_EULER",
"guidanceScaling": 18.6,
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"applyWatermarking": true,
"highNoiseFraction": 0.8,
"inferenceStepCount": 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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the input schema, and the action ID corresponds to the Generate Inpainted Image action. The response will contain the generated image URLs as specified.
Conclusion
The jbilcke/sdxl-brussels Cognitive Actions facilitate seamless image generation and manipulation, empowering developers to create unique visuals with ease. By utilizing the Generate Inpainted Image action, you can harness the power of AI to produce stunning imagery tailored to your specifications. Explore additional use cases such as automated content generation or enhancing existing images with AI-driven insights. Dive into the realm of cognitive actions and elevate your applications today!