Transform Your Images with the kayaeh/adri_flux Cognitive Action

In the realm of image processing, the kayaeh/adri_flux API offers powerful Cognitive Actions that allow developers to harness advanced techniques for image generation and transformation. With the ability to manipulate images through inpainting, you can create stunning visuals tailored to your specifications. This article will guide you through the capabilities of the Generate Image with Inpainting action, providing detailed insights into its use, input requirements, and practical examples.
Prerequisites
Before you dive into using the Cognitive Actions from the kayaeh/adri_flux API, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Familiarity with making HTTP requests and handling JSON data.
- Basic understanding of Python for the usage examples provided.
Authentication typically involves passing your API key in the request headers, enabling secure access to the actions.
Cognitive Actions Overview
Generate Image with Inpainting
The Generate Image with Inpainting action leverages advanced inpainting techniques to generate and transform images. You can adjust various parameters such as image dimensions, aspect ratio, and model selection to achieve the desired output. This action is perfect for developers looking to create dynamic and engaging visuals based on textual prompts.
Category: image-processing
Input
The input for this action requires a JSON object adhering to the following schema:
{
"prompt": "string", // Required
"mask": "string", // Optional: URI of the image mask
"seed": "integer", // Optional: Random seed for generation
"image": "string", // Optional: URI of the input image
"width": "integer", // Optional: Width of the generated image
"goFast": "boolean", // Optional: Enable faster predictions
"height": "integer", // Optional: Height of the generated image
"inferenceModel": "string", // Optional: Model for inference
"imageMegapixels": "string", // Optional: Approximate number of megapixels
"numberOfOutputs": "integer", // Optional: Number of image outputs
"promptIntensity": "number", // Optional: Intensity of the prompt
"imageAspectRatio": "string", // Optional: Aspect ratio for the generated image
"imageOutputFormat": "string", // Optional: Format for output images
"loraStrengthScale": "number", // Optional: Influence of the main LoRA
"additionalLora": "string", // Optional: Load additional LoRA weights
"alternativeWeights": "string", // Optional: Load alternative LoRA weights
"imageOutputQuality": "integer", // Optional: Quality setting for output images
"disableImageSafetyChecker": "boolean" // Optional: Disable safety checker
}
Example Input:
{
"prompt": "ADRI, a 27-year-old adult female, is mid-air in a high-stakes battle over a futuristic cityscape, her red-and-black superhero suit glowing under the neon lights. She’s unleashing a powerful energy blast from her hands, her face intense with concentration and heroic resolve. Below her, skyscrapers reflect the chaos of the ongoing battle, creating an epic and dynamic scene.",
"inferenceModel": "dev",
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"loraStrengthScale": 1,
"imageOutputQuality": 90,
"additionalLoraScale": 1,
"guidanceIntensityScale": 3.5,
"numberOfInferenceSteps": 28
}
Output
Upon execution, the action typically returns a JSON array containing the URLs of the generated images. Here's an example of the expected output:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/86c7a0dd-6427-4a7f-ae3d-a9a4f6a26bd8/ec2ef89a-23a7-4b90-a1fd-efa95e3a4ac7.webp"
]
Conceptual Usage Example (Python)
Here's how you might call the Generate Image with Inpainting 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 = "f97ad6fb-68e8-4996-a10e-58a1db27bd3f" # Action ID for Generate Image with Inpainting
# Construct the input payload based on the action's requirements
payload = {
"prompt": "ADRI, a 27-year-old adult female, is mid-air in a high-stakes battle over a futuristic cityscape, her red-and-black superhero suit glowing under the neon lights. She’s unleashing a powerful energy blast from her hands, her face intense with concentration and heroic resolve. Below her, skyscrapers reflect the chaos of the ongoing battle, creating an epic and dynamic scene.",
"inferenceModel": "dev",
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"loraStrengthScale": 1,
"imageOutputQuality": 90,
"additionalLoraScale": 1,
"guidanceIntensityScale": 3.5,
"numberOfInferenceSteps": 28
}
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 placeholder values with your specific API key and endpoint. The action ID is included, and the input payload is structured according to the requirements outlined in the schema.
Conclusion
The kayaeh/adri_flux Cognitive Action for generating images with inpainting provides developers with an innovative tool to create visually stunning images tailored to their needs. By utilizing the provided parameters, you can control aspects like image quality, aspect ratio, and output format. As you explore this action, consider experimenting with different prompts and settings to fully leverage its capabilities.
Get started today by integrating this action into your applications, and unlock the potential of advanced image processing!