Create Stunning Images with SDXL LoRa Cognitive Actions

In the realm of image generation, the SDXL LoRa Customize Model provides developers with powerful pre-built Cognitive Actions that make creating personalized and stunning visuals easier than ever. This set of actions allows for the seamless integration of advanced image generation techniques into your applications, enhancing user experiences by enabling customized content creation.
Prerequisites
To utilize the SDXL LoRa Cognitive Actions, you will need an API key for the Cognitive Actions platform. This key will be used for authentication. Generally, this involves passing the API key in the headers of your requests to ensure secure access to the services.
Cognitive Actions Overview
Generate Image with SDXL LoRa Model
The Generate Image with SDXL LoRa Model action enables the creation of 1024x1024 images by loading LoRa models via URLs. This action supports a variety of parameters that allow for extensive customization, ensuring that the generated images meet specific needs and preferences.
Input
The input schema for this action is structured as follows:
- loraUrl (required): URL to load the LoRA model required for certain image generation tasks.
- prompt (optional): Descriptive prompt guiding the content of generated images.
- negativePrompt (optional): An opposing prompt to de-emphasize certain aspects in generated images.
- width (optional, default: 1024): The width of the output image in pixels.
- height (optional, default: 1024): The height of the output image in pixels.
- outputQuantity (optional, default: 1): Specifies the number of images to generate (1 to 4).
- guidanceScale (optional, default: 7.5): Scale for classifier-free guidance.
- promptStrength (optional, default: 0.8): Strength of the prompt's influence.
- refineMethod (optional, default: "no_refiner"): Method to refine images post-generation.
- loraIntensity (optional, default: 0.6): Intensity scale for applying LoRA models.
- applyWatermark (optional, default: true): Determines if a watermark is applied.
- schedulingMethod (optional, default: "K_EULER"): Method used for scheduling.
- highNoiseFraction (optional, default: 0.8): Fraction of noise applied in expert ensemble refinement.
- inferenceStepsCount (optional, default: 50): Total number of denoising steps.
Here is an example of the JSON payload needed to invoke the action:
{
"width": 1024,
"height": 1024,
"prompt": "a photo of TOK , white background, pink blazer, american hairstyle",
"loraUrl": "https://replicate.delivery/pbxt/aEt6InPOlTpZJZ9Y1664pLuWBf5ZdIKdjDK4FmHVB2EA47tIA/trained_model.tar",
"refineMethod": "no_refiner",
"guidanceScale": 7.5,
"loraIntensity": 0.6,
"applyWatermark": true,
"outputQuantity": 4,
"promptStrength": 0.8,
"schedulingMethod": "K_EULER",
"highNoiseFraction": 0.8,
"inferenceStepsCount": 20
}
Output
The action typically returns an array of URLs pointing to the generated images. For example:
[
"https://assets.cognitiveactions.com/invocations/7030ba7b-4d57-44c8-a1eb-fc681f5ae908/324d6fe3-6314-46cc-a806-212bd9b8a74b.png",
"https://assets.cognitiveactions.com/invocations/7030ba7b-4d57-44c8-a1eb-fc681f5ae908/e2616a37-7aa9-47df-afac-2f09d14fe890.png",
"https://assets.cognitiveactions.com/invocations/7030ba7b-4d57-44c8-a1eb-fc681f5ae908/aaed7237-b4aa-487a-8033-5156a178ceae.png",
"https://assets.cognitiveactions.com/invocations/7030ba7b-4d57-44c8-a1eb-fc681f5ae908/eb722cbe-36a0-4319-81cd-dc55bad89802.png"
]
Conceptual Usage Example (Python)
Here’s how a developer might call the Cognitive Actions execution 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 = "86763eac-2b48-409f-913b-a54723000cc1" # Action ID for Generate Image with SDXL LoRa Model
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "a photo of TOK , white background, pink blazer, american hairstyle",
"loraUrl": "https://replicate.delivery/pbxt/aEt6InPOlTpZJZ9Y1664pLuWBf5ZdIKdjDK4FmHVB2EA47tIA/trained_model.tar",
"refineMethod": "no_refiner",
"guidanceScale": 7.5,
"loraIntensity": 0.6,
"applyWatermark": True,
"outputQuantity": 4,
"promptStrength": 0.8,
"schedulingMethod": "K_EULER",
"highNoiseFraction": 0.8,
"inferenceStepsCount": 20
}
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 COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual API key and the correct endpoint. The action ID and input payload are structured to match the requirements of the Generate Image with SDXL LoRa Model.
Conclusion
The SDXL LoRa Cognitive Actions provide a powerful and flexible way to generate stunning images tailored to individual needs. With capabilities for extensive customization, developers can create unique visuals that enhance applications and user experiences. Explore the potential of these actions in your projects and unleash your creativity!