Transform Your Images with the Impetus Design Cognitive Actions

In the world of artificial intelligence, image generation and modification are at the forefront of innovation. The Impetus Design Cognitive Actions provide developers with powerful tools to enhance their applications through advanced image processing capabilities. By leveraging pre-built actions, you can integrate image predictions and modifications seamlessly into your projects, saving development time and enhancing functionality.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- API Key: You will need a valid API key to authenticate your requests.
- Endpoint Access: Familiarize yourself with the endpoint you will be using to execute the Cognitive Actions.
Authentication typically involves passing your API key in the headers of your requests.
Cognitive Actions Overview
Generate Image Prediction
The Generate Image Prediction action allows developers to create image predictions based on a URI link to an image, along with optional prompts to guide the generation process. This action is particularly useful for generating high-quality images through multiple inferencing steps.
Input
The action requires the following input fields:
- image (required): A URI link to the image to be processed.
- seed (optional): An integer to initialize the random number generator for reproducibility (default: 92).
- prompt (optional): A text string to influence image generation, which can be left empty.
- padding (optional): A fractional number for padding around the image (default: 0.15).
- numberOfInferenceSteps (optional): The number of steps for inference, influencing output quality (default: 20).
- numberOfImagesPerPrompt (optional): Specifies how many images to generate per prompt (default: 1).
Here’s an example of a valid input JSON payload:
{
"seed": 92,
"image": "https://replicate.delivery/pbxt/MYTyYKwXa8uARHYGYpDv1Kxmea1La0Xoiog5gQ22eaE4GCM2/0.png",
"prompt": "",
"padding": 0.15,
"numberOfInferenceSteps": 20,
"numberOfImagesPerPrompt": 1
}
Output
Upon execution, the action will return an array of image URIs generated based on the provided input. A typical output might look like this:
[
"https://assets.cognitiveactions.com/invocations/338f83e6-5ddc-42cc-ab83-acebeb42c516/6bc764cb-49af-408b-ba9b-deb580cf45fa.png"
]
Conceptual Usage Example (Python)
To help you understand how to call the Generate Image Prediction action, here’s a conceptual Python code snippet that demonstrates how to structure your request:
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 = "ccc7e95f-d760-445b-ba2f-d3090c7e7cf7" # Action ID for Generate Image Prediction
# Construct the input payload based on the action's requirements
payload = {
"seed": 92,
"image": "https://replicate.delivery/pbxt/MYTyYKwXa8uARHYGYpDv1Kxmea1La0Xoiog5gQ22eaE4GCM2/0.png",
"prompt": "",
"padding": 0.15,
"numberOfInferenceSteps": 20,
"numberOfImagesPerPrompt": 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:
- The API key and endpoint URL must be updated with your credentials.
- The action ID and input payload are constructed based on the action's specifications.
- The request is sent to the Cognitive Actions endpoint, and the response is handled appropriately.
Conclusion
The Impetus Design Cognitive Actions empower developers to integrate sophisticated image processing capabilities into their applications effortlessly. With actions like Generate Image Prediction, you can enhance user experiences by providing high-quality image outputs tailored to specific needs. Start exploring these actions today and unlock new possibilities in your projects!