Enhance Your Images with the brettimus/sdxl-paco Cognitive Actions

In today's digital landscape, image enhancement plays a pivotal role in content creation, marketing, and various applications in art and design. The brettimus/sdxl-paco Cognitive Actions offer a powerful API that allows developers to generate enhanced images using the advanced SDXL-PACO model. With capabilities like inpainting and img2img transformations, these pre-built actions simplify the integration of sophisticated image generation into your applications.
Prerequisites
Before you can start using the Cognitive Actions, ensure that you have the following:
- An API key for the Cognitive Actions platform. This key will authenticate your requests.
- Basic knowledge of making API calls, particularly in JSON format.
Authentication typically involves passing your API key in the headers of your requests.
Cognitive Actions Overview
Generate Enhanced Image with SDXL-PACO
This action generates enhanced images utilizing the SDXL-PACO model. It supports various features, including mask input for inpainting, image dimensions, style refinements, and more. This versatility makes it suitable for a range of applications, from artistic renderings to practical enhancements.
Input
The following fields are required or optional for this action:
{
"mask": "string (optional, uri)",
"seed": "integer (optional)",
"image": "string (required, uri)",
"width": "integer (default: 1024)",
"height": "integer (default: 1024)",
"prompt": "string (default: 'An astronaut riding a rainbow unicorn')",
"loraScale": "number (default: 0.6, range: 0-1)",
"scheduler": "string (default: 'K_EULER')",
"outputCount": "integer (default: 1, range: 1-4)",
"refineStyle": "string (default: 'no_refiner')",
"guidanceScale": "number (default: 7.5, range: 1-50)",
"applyWatermark": "boolean (default: true)",
"inferenceSteps": "integer (default: 50, range: 1-500)",
"negativePrompt": "string (optional)",
"promptStrength": "number (default: 0.8, range: 0-1)",
"refinementSteps": "integer (optional)",
"highNoiseFraction": "number (default: 0.8, range: 0-1)"
}
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "a modern impressionist style painting of a happy TOK dog, oil painting on canvas, hill overlooking the sea, greek islands, golden hour, sunset",
"loraScale": 0.75,
"scheduler": "K_EULER",
"outputCount": 4,
"refineStyle": "expert_ensemble_refiner",
"guidanceScale": 7.5,
"applyWatermark": true,
"inferenceSteps": 59,
"negativePrompt": "human, frame",
"promptStrength": 0.8,
"highNoiseFraction": 0.91
}
Output
The action returns an array of URIs pointing to the generated images. Here’s an example of the expected output:
[
"https://assets.cognitiveactions.com/invocations/ca65806d-1a87-456d-8679-f5a65d31cca1/27049135-4629-4261-895d-50c24f4feab3.png",
"https://assets.cognitiveactions.com/invocations/ca65806d-1a87-456d-8679-f5a65d31cca1/fa3e3327-ca1e-4622-b3a9-cb19ac729711.png",
"https://assets.cognitiveactions.com/invocations/ca65806d-1a87-456d-8679-f5a65d31cca1/fc321658-c4c5-47af-b829-9590549989bd.png",
"https://assets.cognitiveactions.com/invocations/ca65806d-1a87-456d-8679-f5a65d31cca1/18b7dd4f-be90-4883-84ed-013996b73f82.png"
]
Conceptual Usage Example (Python)
Here’s how you could structure a conceptual call to the Cognitive Actions 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 = "a98d9133-62b7-4003-8b42-f04bef2d5a47" # Action ID for Generate Enhanced Image with SDXL-PACO
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "a modern impressionist style painting of a happy TOK dog, oil painting on canvas, hill overlooking the sea, greek islands, golden hour, sunset",
"loraScale": 0.75,
"scheduler": "K_EULER",
"outputCount": 4,
"refineStyle": "expert_ensemble_refiner",
"guidanceScale": 7.5,
"applyWatermark": True,
"inferenceSteps": 59,
"negativePrompt": "human, frame",
"promptStrength": 0.8,
"highNoiseFraction": 0.91
}
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 will replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the action's requirements. Note that the endpoint URL and request structure are illustrative and may need to be adjusted for your specific implementation.
Conclusion
The brettimus/sdxl-paco Cognitive Actions provide a powerful tool for developers looking to enhance their applications with advanced image generation capabilities. By leveraging these actions, you can easily create visually stunning content tailored to your specific needs. Start integrating these actions today to unlock new creative possibilities in your projects!