Generate Stunning Custom Images with abarzuamedios/leg Cognitive Actions

Integrating advanced image generation capabilities into your applications has never been easier with the abarzuamedios/leg Cognitive Actions. This API allows developers to generate custom images using sophisticated techniques like image inpainting and image-to-image transformations. By leveraging these pre-built actions, you can enhance your projects with unique visual content tailored to your specifications, saving time and resources while delivering exceptional results.
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 knowledge of JSON structure to format your inputs correctly.
Authentication typically involves passing the API key in the request headers to access the actions securely.
Cognitive Actions Overview
Generate Custom Images
The Generate Custom Images action allows you to create custom images by providing a prompt and various customization options, including aspect ratio, quality, and model choice. This action falls under the image-generation category.
Input
The following JSON schema outlines the required and optional fields for this action:
{
"prompt": "string (required)",
"mask": "string (optional, uri)",
"seed": "integer (optional)",
"image": "string (optional, uri)",
"model": "string (optional, enum: [dev, schnell], default: dev)",
"width": "integer (optional)",
"height": "integer (optional)",
"fastMode": "boolean (optional, default: false)",
"loraScale": "number (optional, default: 1)",
"megapixels": "string (optional, enum: [1, 0.25], default: 1)",
"aspectRatio": "string (optional, enum: [1:1, 16:9, custom], default: 1:1)",
"imageFormat": "string (optional, enum: [webp, jpg, png], default: webp)",
"outputCount": "integer (optional, default: 1)",
"imageQuality": "integer (optional, default: 80)",
"guidanceScale": "number (optional, default: 3)",
"inferenceSteps": "integer (optional, default: 28)",
"promptStrength": "number (optional, default: 0.8)",
"additionalLoraScale": "number (optional, default: 1)",
"safetyCheckerDisabled": "boolean (optional, default: false)"
}
Example Input:
{
"model": "dev",
"prompt": "entregame una imagen del rostro de LEG mirando hacia el costado, en el fondo se ve un parque",
"fastMode": false,
"loraScale": 1,
"megapixels": "1",
"aspectRatio": "1:1",
"imageFormat": "webp",
"outputCount": 1,
"imageQuality": 80,
"guidanceScale": 3,
"inferenceSteps": 28,
"promptStrength": 0.8,
"additionalLoraScale": 1
}
Output
The action typically returns a URL to the generated image. Here’s an example of the output structure:
[
"https://assets.cognitiveactions.com/invocations/18cd7557-f9a7-4d46-816f-8e9072a09ff8/6e70c160-a074-459d-a452-e49408661797.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate Custom Images action 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 = "129edd17-19f0-4f3d-8f21-2455a6c157c9" # Action ID for Generate Custom Images
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "entregame una imagen del rostro de LEG mirando hacia el costado, en el fondo se ve un parque",
"fastMode": False,
"loraScale": 1,
"megapixels": "1",
"aspectRatio": "1:1",
"imageFormat": "webp",
"outputCount": 1,
"imageQuality": 80,
"guidanceScale": 3,
"inferenceSteps": 28,
"promptStrength": 0.8,
"additionalLoraScale": 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, you replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is structured according to the input requirements of the Generate Custom Images action, ensuring that all necessary parameters are included.
Conclusion
The abarzuamedios/leg Cognitive Actions present a powerful solution for developers looking to integrate image generation capabilities into their applications. By utilizing the Generate Custom Images action, you can create tailored visuals that enhance user engagement and experience. Start experimenting with these actions today to unlock new creative possibilities in your projects!