Create Stunning Images with Cognitive Actions from leonardoa2/eliazumaabiti

In the world of digital artistry and creative applications, the ability to generate images with precision and style can set your projects apart. The Cognitive Actions offered by the leonardoa2/eliazumaabiti spec provide powerful tools for image generation, including advanced techniques like inpainting. These pre-built actions simplify the integration of complex image generation functionalities into your applications, allowing you to focus on creativity rather than technical hurdles.
Prerequisites
Before you start using the Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Basic understanding of RESTful API concepts and JSON structure.
- Familiarity with making HTTP requests in your programming environment.
Authentication typically involves passing your API key in the request headers, ensuring secure access to the Cognitive Actions.
Cognitive Actions Overview
Generate Image with Inpainting
Description: This operation creates a generated image using image inpainting techniques. It allows customization of dimensions, aspect ratios, and image quality. The action supports fast generation mode and utilizes the 'dev' or 'schnell' model for enhanced speed and efficiency.
Category: image-generation
Input: The input schema for this action requires the following fields:
- prompt (required): The description of the image you want to generate.
- mask (optional): An image mask for image inpainting mode.
- seed (optional): An integer that determines the random seed for replicable image generation.
- image (optional): An input image for inpainting mode.
- model (optional): Choose between 'dev' or 'schnell' for different generation speeds.
- width (optional): Width of the generated image (only for custom aspect ratios).
- height (optional): Height of the generated image (only for custom aspect ratios).
- fastMode (optional): Boolean to optimize for faster predictions.
- megaPixels (optional): Defines resolution in megapixels.
- aspectRatio (optional): Specifies the aspect ratio of the image.
- imageFormat (optional): File format for the output images (e.g., webp, jpg, png).
- imageQuality (optional): Quality level for saving output images.
- numberOfOutputs (optional): Number of images to generate in one operation.
Example Input:
{
"model": "dev",
"prompt": "An elegant women’s dress with classic, tailored lines, accented with traditional African fabrics and patterns on select sections, inspired by the trigger TOKELIAZUMAABITI reference folder. The dress combines timeless sophistication with vibrant cultural elements, featuring rich tones like emerald green or royal purple, with bold, intricate African patterns on the sleeves, waist, and neckline. The woman stands outdoors in bright, natural sunlight, with a background of soft, sandy-beige tones that contrast with the cool, jewel-toned hues of the dress. She is posed symmetrically in the style of Wes Anderson, with hands at her sides and a poised, graceful expression. The scene is photorealistic, with vivid lighting that emphasizes both the refined structure of the dress and the striking traditional accents.",
"aspectRatio": "1:1",
"imageFormat": "webp",
"imageQuality": 90,
"loraIntensity": 1,
"promptStrength": 0.8,
"numberOfOutputs": 2,
"guidanceStrength": 3.5,
"numberOfInferenceSteps": 28,
"additionalLoraIntensity": 1
}
Output: The action typically returns an array of URLs pointing to the generated images.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/2c14dfd1-f0c0-407c-8e26-f3e785bdd4bf/26b5370b-e0fd-4837-9e6c-b307b61a2b58.webp",
"https://assets.cognitiveactions.com/invocations/2c14dfd1-f0c0-407c-8e26-f3e785bdd4bf/f447e766-66b5-4664-afa7-9f5e00f5f4f7.webp"
]
Conceptual Usage Example (Python): Here is a Python code snippet to demonstrate how you might invoke this 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 = "d936c2cc-42a3-4a63-82a9-b19a258990e8" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "An elegant women’s dress with classic, tailored lines, accented with traditional African fabrics...",
"aspectRatio": "1:1",
"imageFormat": "webp",
"imageQuality": 90,
"loraIntensity": 1,
"promptStrength": 0.8,
"numberOfOutputs": 2,
"guidanceStrength": 3.5,
"numberOfInferenceSteps": 28,
"additionalLoraIntensity": 1
}
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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is constructed based on the example input schema, ensuring the request meets the action's requirements.
Conclusion
The Generate Image with Inpainting action from the leonardoa2/eliazumaabiti spec offers developers a robust tool for creating stunning images with various customization options. By leveraging these Cognitive Actions, you can enhance your applications' creative capabilities and streamline your image generation processes.
Explore the potential of integrating these actions into your projects, and start creating visually captivating content today!