Create Stunning Images with the Mia LoRA Cognitive Actions

In today's visually-driven digital landscape, the ability to generate high-quality images programmatically can significantly enhance your applications. The Mia LoRA Cognitive Actions provide developers with a powerful toolset for creating customized images with various parameters. This blog post will guide you through the Generate Customized Image action, allowing you to harness the potential of the Mia LoRA model for your projects.
Prerequisites
Before diving into the integration of the Mia LoRA Cognitive Actions, ensure that you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of making HTTP requests and handling JSON data.
For authentication, you typically pass the API key in the headers of your requests, allowing secure access to the Cognitive Actions.
Cognitive Actions Overview
Generate Customized Image
The Generate Customized Image action allows you to create high-quality images using the Mia LoRA model. You can customize various settings such as aspect ratio, resolution, and output format, making it versatile for multiple use cases.
Input
The input schema for this action is a JSON object that includes the following fields:
- prompt (required): A descriptive text that guides the image generation.
- model (optional): The inference model to be used (default:
dev). - aspectRatio (optional): Desired aspect ratio of the generated image (default:
1:1). - outputFormat (optional): The format of the output image (default:
webp). - guidanceLevel (optional): A scale that influences the generation (default:
3). - mainLoraScale (optional): The strength of the main LoRA application (default:
1). - outputQuality (optional): Image quality from
0to100(default:80). - denoisingSteps (optional): The number of denoising steps for image clarity (default:
28). - promptStrength (optional): Strength of the prompt when using image input (default:
0.8). - numberOfOutputs (optional): How many images to generate (default:
1). - additionalLoraScale (optional): Adjusts the intensity of additional LoRA application (default:
1).
Example Input:
{
"model": "dev",
"prompt": "a professional portrait shot of MIA a female blonde influencer, perfect skin texture, perfect hair, perfect light, low saturation",
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceLevel": 2,
"mainLoraScale": 1,
"outputQuality": 90,
"denoisingSteps": 28,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"additionalLoraScale": 1
}
Output
Upon successful execution, this action returns a URL pointing to the generated image. The structure of the response is as follows:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/bd455b3c-38e8-4fdc-ab4f-90bfab6605dc/63ff1a6f-b2d1-40e9-8f2b-122a7e2416d2.webp"
]
Conceptual Usage Example (Python)
Here’s how you can invoke the Generate Customized Image 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 = "3b612c79-e4fd-49ab-a2d3-7ffd250e177f" # Action ID for Generate Customized Image
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "a professional portrait shot of MIA a female blonde influencer, perfect skin texture, perfect hair, perfect light, low saturation",
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceLevel": 2,
"mainLoraScale": 1,
"outputQuality": 90,
"denoisingSteps": 28,
"promptStrength": 0.8,
"numberOfOutputs": 1,
"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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The input payload is constructed based on the required fields, and you can easily modify the parameters to fit your specific use case.
Conclusion
The Mia LoRA Cognitive Actions empower developers to create stunning images with a variety of customizable options. By integrating the Generate Customized Image action into your applications, you can enhance user experience and provide unique visual content. Explore the potential of image generation and start building your creative projects today!