Generate Customized Images with the Visoar/Cat-Xiaobai Cognitive Actions

The Visoar/Cat-Xiaobai API offers powerful Cognitive Actions designed to enhance image generation capabilities. With the ability to produce customized images using advanced features like inpainting, mask application, and image refinement, developers can easily integrate these actions into their applications. These pre-built actions not only save time but also enable the creation of high-quality images tailored to specific needs.
Prerequisites
To get started using the Visoar/Cat-Xiaobai Cognitive Actions, you will need:
- An API key for the Cognitive Actions platform.
- Basic knowledge of JSON and Python for constructing API calls.
Authentication is typically handled by passing your API key in the request headers. This allows you to securely access the Cognitive Actions endpoints.
Cognitive Actions Overview
Generate Customized Image with Xiaobai
The Generate Customized Image with Xiaobai action allows you to produce tailored images by utilizing the Xiaobai model. This action supports various features, including inpainting and mask application, to refine and enhance the generated images further.
Input
The input schema for this action includes several configurable parameters:
- prompt (string, required): Text prompt guiding the image generation (default: "An astronaut riding a rainbow unicorn").
- width (integer, optional): Width of the output image in pixels (default: 1024).
- height (integer, optional): Height of the output image in pixels (default: 1024).
- image (string, optional): URI of the input image for img2img or inpaint mode operations.
- mask (string, optional): URI of the input mask used in inpaint mode.
- negativePrompt (string, optional): Specifies undesired outcomes in the generated image.
- numberOfOutputs (integer, optional): Number of images to generate (default: 1).
- guidanceScale (number, optional): Guidance intensity ranging from 1 to 50 (default: 7.5).
- loraScale (number, optional): LoRA additive scale factor (default: 0.6).
- applyWatermark (boolean, optional): Whether to apply a watermark to the output image (default: true).
- refinementMethod (string, optional): Method for refining the image (default: "no_refiner").
- schedulingMethod (string, optional): Method for scheduling image generation steps (default: "K_EULER").
- numberOfInferenceSteps (integer, optional): Steps for denoising during inference (default: 50).
- promptStrength (number, optional): Impact of the prompt (default: 0.8).
Example Input
{
"width": 1024,
"height": 1024,
"prompt": "photo of TOK,photo of TOK",
"loraScale": 0.95,
"guidanceScale": 7.5,
"applyWatermark": false,
"negativePrompt": ",NSFW",
"numberOfOutputs": 1,
"schedulingMethod": "K_EULER"
}
Output
The action typically returns a list of URLs pointing to the generated images.
Example Output
[
"https://assets.cognitiveactions.com/invocations/84963e4e-9463-4208-93a2-ab16e927b05a/8704f013-273d-4003-aa99-0643d0615fd5.png"
]
Conceptual Usage Example (Python)
Here’s a conceptual Python code snippet demonstrating how to call the Generate Customized Image with Xiaobai action:
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 = "fe286703-0054-42a2-8133-90095db2cd78" # Action ID for Generate Customized Image with Xiaobai
# Construct the input payload based on the action's requirements
payload = {
"width": 1024,
"height": 1024,
"prompt": "photo of TOK,photo of TOK",
"loraScale": 0.95,
"guidanceScale": 7.5,
"applyWatermark": False,
"negativePrompt": ",NSFW",
"numberOfOutputs": 1,
"schedulingMethod": "K_EULER"
}
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 need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID and input payload are structured according to the requirements, allowing you to generate customized images seamlessly.
Conclusion
The Visoar/Cat-Xiaobai Cognitive Actions provide powerful tools for image generation, offering flexibility and control over the creative process. By leveraging these actions, developers can easily incorporate advanced image generation features into their applications. Consider experimenting with different input parameters to discover the best results for your specific use cases!