Enhance Your Images with the zeg06/felix Cognitive Actions

In today's digital landscape, the ability to generate and enhance images programmatically can significantly elevate your application’s capabilities. The zeg06/felix Cognitive Actions provide a powerful set of tools for image generation, inpainting, and enhancement. With these pre-built actions, developers can easily create stunning visuals tailored to specific needs without diving deep into complex algorithms or models.
Prerequisites
Before you start using the Cognitive Actions, ensure you have the following:
- API Key: You will need an API key to authenticate your requests to the Cognitive Actions platform.
- Setup: Familiarize yourself with the basic structure of JSON payloads as you will be constructing requests using this format.
To authenticate your requests, you typically pass your API key in the headers of your HTTP requests.
Cognitive Actions Overview
Generate Image with Inpainting and Enhancement
This action allows you to generate and enhance images using inpainting alongside various customizable settings, including aspect ratio, image dimensions, guidance scales, and LoRA intensity. It supports control over the output format and image quality, making it versatile for different applications.
Input
The input schema for this action is structured as follows:
- prompt (required): A descriptive text guiding the image generation.
- mask (optional): URI of the image mask for inpainting mode.
- seed (optional): An integer for consistent image generation outcomes.
- image (optional): URI of the input image for transformations or inpainting.
- width (optional): Custom width of the generated image in pixels (256-1440).
- height (optional): Custom height of the generated image in pixels (256-1440).
- imageFormat (optional): Output image format (default is
webp). - imageQuality (optional): Quality of the output image (0-100).
- modelWeights (optional): Source for LoRA weights.
- loraIntensity (optional): Influence of the primary LoRA (range -1 to 3).
- enableFastMode (optional): Toggle fast predictions (default is
false). - inferenceModel (optional): Choose model for inference (
devorschnell). - imageMegapixels (optional): Total megapixels for the generated image.
- numberOfOutputs (optional): Number of images to generate (1-4).
- promptIntensity (optional): Strength of the prompt alteration (0-1).
- imageAspectRatio (optional): Aspect ratio for the image.
- diffusionGuidance (optional): Guidance scale during diffusion (0-10).
- inferenceStepCount (optional): Number of denoising steps (1-50).
- additionalLoraWeights (optional): Source for extra LoRA weights.
- safetyCheckerDisabled (optional): Disable the safety checker (default is
false). - additionalLoraIntensity (optional): Controls the application of additional LoRA.
Example Input:
{
"prompt": "realistic photo of felix in a classy suit. very muscular, very classy, dark background",
"imageFormat": "webp",
"imageQuality": 100,
"loraIntensity": 1,
"enableFastMode": false,
"inferenceModel": "dev",
"imageMegapixels": "1",
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"diffusionGuidance": 3,
"inferenceStepCount": 50,
"additionalLoraIntensity": 1
}
Output
The action returns a list of URLs pointing to the generated images. For example:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/f830a9b5-84e9-4e19-ba9c-9591e73aedc4/13ff946e-d37d-4058-865d-aa3023d5d534.webp"
]
This URL can be used to access the generated image directly.
Conceptual Usage Example (Python)
Here's how you might invoke this action in a Python application:
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 = "9e41a016-89e3-4427-9038-37b46d77895a" # Action ID for Generate Image with Inpainting and Enhancement
# Construct the input payload based on the action's requirements
payload = {
"prompt": "realistic photo of felix in a classy suit. very muscular, very classy, dark background",
"imageFormat": "webp",
"imageQuality": 100,
"loraIntensity": 1,
"enableFastMode": False,
"inferenceModel": "dev",
"imageMegapixels": "1",
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"diffusionGuidance": 3,
"inferenceStepCount": 50,
"additionalLoraIntensity": 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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the "Generate Image with Inpainting and Enhancement" action. The payload is structured according to the schema requirements outlined above.
Conclusion
The zeg06/felix Cognitive Actions offer a robust solution for developers seeking to incorporate advanced image generation and enhancement features into their applications. By leveraging these actions, you can create customized and high-quality images tailored to your specific needs. Explore the myriad possibilities these tools open up and consider how they can enhance your projects. Happy coding!