Generate Stunning Images with the hadasadler/taligotliv Cognitive Actions

In today's world, where visual content is paramount, the hadasadler/taligotliv Cognitive Actions provide developers with powerful tools to generate stunning and customized images. This set of pre-built actions leverages advanced image generation techniques, including inpainting and image-to-image modes, making it easier for developers to integrate sophisticated image generation capabilities into their applications. With support for various aspect ratios and quality settings, you can create images tailored to your specific needs with minimal effort.
Prerequisites
Before you begin using the Cognitive Actions, ensure that you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic understanding of JSON structure for constructing your requests.
Authentication is typically handled by including your API key in the request headers, allowing you to securely call the Cognitive Actions endpoints.
Cognitive Actions Overview
Generate Customized Image
The Generate Customized Image action allows you to create tailored images using advanced techniques such as inpainting and image-to-image generation. This action supports various settings to customize the output, including aspect ratios, image quality, and model selections for quality or speed.
Input
The input for this action is defined by the following schema, where the prompt is the only required field:
{
"prompt": "string", // Required: Description for the generated image.
"mask": "string", // Optional: Image mask for inpainting mode.
"seed": "integer", // Optional: Random seed for reproducibility.
"image": "string", // Optional: Input image for img2img or inpainting.
"width": "integer", // Optional: Width of the generated image.
"height": "integer", // Optional: Height of the generated image.
"imageFormat": "string", // Optional: Format of the output image (e.g., webp, jpg, png).
"outputCount": "integer", // Optional: Number of outputs to generate (default is 1).
"denoisingSteps": "integer", // Optional: Number of denoising steps for detail.
"inferenceModel": "string", // Optional: Model for inference (dev or schnell).
"imageAspectRatio": "string", // Optional: Aspect ratio for the image.
"imageOutputQuality": "integer", // Optional: Quality of the output image (0-100).
"accelerateInference": "boolean", // Optional: Enable faster predictions mode.
"approximateMegapixels": "string", // Optional: Approximate megapixels for the image.
"img2imgPromptStrength": "number", // Optional: Prompt strength for img2img generation.
"safetyCheckerDisabled": "boolean", // Optional: Disable safety checker for generated images.
"diffusionGuidanceScale": "number", // Optional: Guidance scale for diffusion (0-10).
"mainLoraApplicationScale": "number", // Optional: Main LoRA application scale.
"additionalLoraApplicationScale": "number" // Optional: Additional LoRA application scale.
}
Example Input:
Here is an example payload to invoke this action:
{
"prompt": "taligotliv A highly realistic woman looking to the camera",
"imageFormat": "jpg",
"outputCount": 1,
"denoisingSteps": 28,
"inferenceModel": "dev",
"imageAspectRatio": "16:9",
"imageOutputQuality": 80,
"accelerateInference": false,
"approximateMegapixels": "1",
"img2imgPromptStrength": 0.8,
"diffusionGuidanceScale": 3,
"mainLoraApplicationScale": 1,
"additionalLoraApplicationScale": 1
}
Output
Upon successful execution, this action returns a list of URLs pointing to the generated images. For example:
[
"https://assets.cognitiveactions.com/invocations/64bba1c7-e99a-42a0-89e2-62d71442dfce/cade76e3-f493-4422-af42-d7e88fe2279f.jpg"
]
Conceptual Usage Example (Python)
Below is a conceptual Python code snippet demonstrating how to call the Generate Customized Image 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 = "056f6776-26ee-4c85-80f6-ecc6c826b8fa" # Action ID for Generate Customized Image
# Construct the input payload based on the action's requirements
payload = {
"prompt": "taligotliv A highly realistic woman looking to the camera",
"imageFormat": "jpg",
"outputCount": 1,
"denoisingSteps": 28,
"inferenceModel": "dev",
"imageAspectRatio": "16:9",
"imageOutputQuality": 80,
"accelerateInference": False,
"approximateMegapixels": "1",
"img2imgPromptStrength": 0.8,
"diffusionGuidanceScale": 3,
"mainLoraApplicationScale": 1,
"additionalLoraApplicationScale": 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 Python snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your API key, and the action_id corresponds to the Generate Customized Image action. The payload is structured according to the input schema, and the response will provide URLs for the generated images.
Conclusion
The hadasadler/taligotliv Cognitive Actions empower developers to create visually appealing and customized images effortlessly. With a variety of parameters to adjust, you can fine-tune each image to meet your specific requirements. Whether you're building a creative application or integrating image generation into existing projects, these actions offer a robust solution. Start exploring the possibilities today!