Enhance Your Images with SDXL Fine-Tuning: A Developer's Guide

In the world of digital content, visual quality is paramount. The fofr/sdxl-wrong API offers a powerful Cognitive Action that allows developers to enhance low-quality images using SDXL fine-tuning. With this pre-built action, you can refine image characteristics, adjust output dimensions, and even apply or remove watermarks, all with a few lines of code. This guide will walk you through the capabilities of this action, enabling you to integrate image enhancement seamlessly into your applications.
Prerequisites
Before diving into the integration of the Cognitive Action, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Basic knowledge of making HTTP requests in your programming language of choice.
- A working environment set up for making API calls, such as Python with the
requestslibrary.
Authentication typically involves passing your API key in the headers of your requests, allowing you to securely access the service.
Cognitive Actions Overview
Enhance Images with SDXL Fine-Tuning
This action is designed to improve low-quality 2048x2048 images by enhancing their visual quality. It provides capabilities for refining images in various ways, including adjusting their output dimensions and watermarking.
Category: Image Enhancement
Input
The input schema for this action is structured as follows:
{
"mask": "string (uri, optional)",
"seed": "integer (optional)",
"image": "string (uri, required)",
"width": "integer (default: 1024)",
"height": "integer (default: 1024)",
"prompt": "string (default: 'An astronaut riding a rainbow unicorn')",
"loraWeights": "string (optional)",
"scheduleType": "string (default: 'K_EULER')",
"applyWatermark": "boolean (default: true)",
"numberOfOutputs": "integer (default: 1, min: 1, max: 4)",
"promptIntensity": "number (default: 0.8, min: 0, max: 1)",
"refinementSteps": "integer (optional)",
"refinementStyle": "string (default: 'no_refiner')",
"highNoiseFraction": "number (default: 0.8, min: 0, max: 1)",
"inferenceStepsCount": "integer (default: 50, min: 1, max: 500)",
"loraAdjustmentScale": "number (default: 0.6, min: 0, max: 1)",
"negativePromptInput": "string (optional)",
"guidanceAdjustmentScale": "number (default: 7.5, min: 1, max: 50)",
"disableImageSafetyChecker": "boolean (default: false)"
}
Example Input:
{
"width": 1024,
"height": 1024,
"prompt": "A TOK image",
"scheduleType": "K_EULER",
"applyWatermark": true,
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"refinementStyle": "no_refiner",
"highNoiseFraction": 0.8,
"inferenceStepsCount": 50,
"loraAdjustmentScale": 0.6,
"negativePromptInput": "",
"guidanceAdjustmentScale": 7.5
}
Output
Upon successful execution, the action typically returns a list of URLs pointing to the enhanced images. Here’s an example of what you might receive:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/e3bcee2e-2c45-4df5-b6b8-2f09d3b3b1e2/f88bd3e0-3e3d-4f9d-bc73-2d12aaa35697.png"
]
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet demonstrating how to invoke the "Enhance Images with SDXL Fine-Tuning" action using the hypothetical Cognitive Actions execution endpoint:
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 = "722ad7b5-803e-4a8b-984a-4ada610dbf83" # Action ID for Enhance Images with SDXL Fine-Tuning
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "A TOK image",
"scheduleType": "K_EULER",
"applyWatermark": True,
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"refinementStyle": "no_refiner",
"highNoiseFraction": 0.8,
"inferenceStepsCount": 50,
"loraAdjustmentScale": 0.6,
"negativePromptInput": "",
"guidanceAdjustmentScale": 7.5
}
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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id variable should be set to the ID of the action you want to execute. The input payload is constructed based on the requirements outlined above. The response is captured and printed in a readable format.
Conclusion
The "Enhance Images with SDXL Fine-Tuning" action offers developers a robust solution for improving image quality in their applications. By utilizing this Cognitive Action, you can automate visual enhancements, refine image characteristics, and manage watermarks with ease.
Consider exploring other use cases, such as batch processing or integrating with image galleries, to fully leverage the capabilities of this API. Happy coding!