Harnessing the Power of Image Generation with asiryan/deliberate-v5 Cognitive Actions

The asiryan/deliberate-v5 API offers developers an innovative way to create stunning images through various methods like generating images from text prompts, modifying existing images, or conducting inpainting. This set of Cognitive Actions simplifies the image generation process while providing customizable options to enhance the quality and specificity of the outputs. By leveraging these pre-built actions, developers can save time and resources while integrating powerful image generation capabilities into their applications.
Prerequisites
Before you start using the Cognitive Actions from the asiryan/deliberate-v5 API, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic understanding of JSON and RESTful API concepts.
- Familiarity with Python for implementing the conceptual usage examples.
Authentication typically involves passing your API key in the request headers, which grants you access to the functionalities provided by the API.
Cognitive Actions Overview
Generate Image using Deliberate V5
The Generate Image using Deliberate V5 action enables you to create images based on text prompts, modify existing images, or perform inpainting. This versatile action supports various functionalities including Text2Img, Img2Img, and inpainting, allowing for extensive customization of the generated images.
Category: image-generation
Input
The input for this action requires a JSON object structured as follows:
{
"mask": "uri_of_mask_image",
"seed": 12345,
"image": "uri_of_input_image",
"width": 512,
"height": 728,
"prompt": "person, 200mm",
"strength": 1,
"scheduler": "K_EULER_ANCESTRAL",
"guidanceScale": 7.5,
"negativePrompt": "[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",
"useKarrasSigmas": false,
"numInferenceSteps": 20
}
Example Input:
{
"width": 512,
"height": 728,
"prompt": "person, 200mm",
"strength": 1,
"scheduler": "K_EULER_ANCESTRAL",
"guidanceScale": 7.5,
"negativePrompt": "[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",
"useKarrasSigmas": false,
"numInferenceSteps": 20
}
Output
Upon successful execution, the action returns a URL pointing to the generated image.
Example Output:
https://assets.cognitiveactions.com/invocations/513981f7-748a-4a2a-a6a1-1bdf8d4780cd/e5ae5e7a-df76-4fe9-857e-4cf7ad773190.png
Conceptual Usage Example (Python)
Here’s how you can call the Generate Image using Deliberate V5 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 = "47b8f329-29f8-488a-9817-889507f1e159" # Action ID for Generate Image using Deliberate V5
# Construct the input payload based on the action's requirements
payload = {
"width": 512,
"height": 728,
"prompt": "person, 200mm",
"strength": 1,
"scheduler": "K_EULER_ANCESTRAL",
"guidanceScale": 7.5,
"negativePrompt": "[deformed | disfigured], poorly drawn, [bad : wrong] anatomy, [extra | missing | floating | disconnected] limb, (mutated hands and fingers), blurry",
"useKarrasSigmas": False,
"numInferenceSteps": 20
}
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 the above snippet, replace the placeholder for YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload structure needs to match the requirements outlined in the input schema. This code demonstrates how to send a request to a hypothetical endpoint for executing the Generate Image using Deliberate V5 action.
Conclusion
The asiryan/deliberate-v5 Cognitive Actions provide a robust framework for image generation and manipulation, allowing developers to seamlessly integrate advanced image processing capabilities into their applications. By taking advantage of the customizable parameters offered by the Generate Image using Deliberate V5 action, you can generate high-quality images tailored to specific needs. Explore further use cases, experiment with different parameters, and unlock the full potential of image generation in your projects!