Create Stunning Images with the Ericsson230 Faith LoRA Cognitive Actions

In the realm of image processing, the Ericsson230 Faith LoRA Cognitive Actions provide powerful capabilities for generating and modifying images. By leveraging advanced inference models, these actions enable developers to create new images or enhance existing ones through inpainting with customizable parameters. With support for various file formats and aspect ratios, these pre-built actions simplify the integration of sophisticated image generation features into your applications.
Prerequisites
Before you can start using the Ericsson230 Faith LoRA Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic familiarity with JSON payload structure.
- A working Python environment with the
requestslibrary installed for making API calls.
Authentication typically involves passing the API key in the request headers, allowing you to securely access the Cognitive Actions services.
Cognitive Actions Overview
Generate And Inpaint Image
The Generate And Inpaint Image action is designed for creating new images or performing inpainting tasks based on specified image inputs and prompts. This action allows for variable steps and quality settings, ensuring flexibility in output based on your needs.
Input
The input to this action requires a structured JSON object. The primary required field is the prompt, while several optional fields allow for extensive customization:
{
"prompt": "falex dressed as wonderwoman",
"fastMode": false,
"loraScale": 1,
"imageFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"inferenceModel": "dev",
"imageMegapixels": "1",
"numberOfOutputs": 4,
"imageAspectRatio": "1:1",
"numInferenceSteps": 50,
"additionalLoraScale": 1,
"imagePromptStrength": 0.8
}
Key Input Fields:
prompt(string, required): Describes what the generated image should depict.image(string, optional): URI of an input image for transformations.mask(string, optional): URI of an image mask for inpainting.width(integer, optional): Custom width for the generated image.height(integer, optional): Custom height for the generated image.fastMode(boolean, optional): Enables faster predictions.numberOfOutputs(integer, optional): Specifies how many images to generate (up to 4).
Output
The action returns an array of URLs pointing to the generated images. Each URL corresponds to an image created based on the input parameters.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/7b2fab5c-e540-432e-b27f-a3f9fdeb14a1/941d9d2f-5060-414b-9405-9685c7acb76f.webp",
"https://assets.cognitiveactions.com/invocations/7b2fab5c-e540-432e-b27f-a3f9fdeb14a1/1a923fdf-8d95-4c8e-8584-7d95559dea65.webp",
"https://assets.cognitiveactions.com/invocations/7b2fab5c-e540-432e-b27f-a3f9fdeb14a1/33dcfb53-ca8c-4b5d-96af-ba02cafa997b.webp",
"https://assets.cognitiveactions.com/invocations/7b2fab5c-e540-432e-b27f-a3f9fdeb14a1/be9cf135-de4b-44ae-af04-8073d12949df.webp"
]
Conceptual Usage Example (Python)
Here’s how you can call the Generate And Inpaint 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 = "b883f308-ea31-4447-82f4-7b898d3641b0" # Action ID for Generate And Inpaint Image
# Construct the input payload based on the action's requirements
payload = {
"prompt": "falex dressed as wonderwoman",
"fastMode": False,
"loraScale": 1,
"imageFormat": "webp",
"guidanceScale": 3,
"outputQuality": 80,
"inferenceModel": "dev",
"imageMegapixels": "1",
"numberOfOutputs": 4,
"imageAspectRatio": "1:1",
"numInferenceSteps": 50,
"additionalLoraScale": 1,
"imagePromptStrength": 0.8
}
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 code snippet, make sure to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured based on the action's input schema, allowing you to customize image generation as needed.
Conclusion
The Ericsson230 Faith LoRA Cognitive Actions provide robust capabilities for image generation and inpainting, making it easier for developers to integrate advanced image processing features into their applications. With a range of customizable parameters, you can optimize image quality and style to meet your specific needs. Explore these actions further and consider how they can enhance your projects in creative and practical ways!