Enhance Your Images with the Bishorahu/Prajwal Cognitive Actions

In the world of image generation, the Bishorahu/Prajwal API offers developers a powerful set of Cognitive Actions that enable the creation and enhancement of images through advanced techniques like inpainting and image-to-image transformations. These pre-built actions streamline the process of producing high-quality images with customizable parameters, allowing for a wide range of applications from creative art to professional photography editing.
Prerequisites
Before you can start utilizing the Cognitive Actions, ensure you have the following:
- An API key for the Bishorahu/Prajwal platform.
- Familiarity with making HTTP requests and handling JSON data.
- A basic understanding of image formats and resolutions.
Authentication typically involves passing your API key in the request headers, allowing you to securely access the Cognitive Actions.
Cognitive Actions Overview
Generate Enhanced Images
The Generate Enhanced Images action allows developers to create images using various models, leveraging features like image customization, resolution adjustments, and aspect ratios. This action is ideal for users looking to generate unique visuals based on specific prompts.
Input
The input schema for this action requires the following fields:
- prompt (required): A string that guides the image generation process.
- model: Choose between "dev" for detailed results or "schnell" for faster processing.
- aspectRatio: Define the aspect ratio for the image, with options including "1:1", "16:9", and custom ratios.
- numOutputs: Specify how many images to generate (1-4).
- outputFormat: Select the format of the output image, such as "webp", "jpg", or "png".
- Additional parameters include guidanceScale, outputQuality, and various scaling options for enhanced customization.
Here's an example input JSON payload:
{
"model": "dev",
"prompt": "portrait photo of a boy (TOK), he is eating icecream, clear photo",
"loraScale": 1.14,
"numOutputs": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"promptStrength": 0.8,
"numInferenceSteps": 23,
"additionalLoraScale": 1.02
}
Output
The action typically returns a list of URLs pointing to the generated images. Here's an example of the output you might receive:
[
"https://assets.cognitiveactions.com/invocations/4a33f952-947d-4e92-bf03-ff14d56dfbeb/a367f4a1-1b69-407a-b546-5f3cab571cd6.webp"
]
Conceptual Usage Example (Python)
To invoke the Generate Enhanced Images action, you can use the following Python code snippet. This example illustrates how to structure the input JSON and make a request to the hypothetical Cognitive Actions execution endpoint.
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 = "9966c782-a5a6-4604-ac92-e608c70bf21f" # Action ID for Generate Enhanced Images
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "portrait photo of a boy (TOK), he is eating icecream, clear photo",
"loraScale": 1.14,
"numOutputs": 1,
"aspectRatio": "1:1",
"outputFormat": "webp",
"guidanceScale": 3.5,
"outputQuality": 90,
"promptStrength": 0.8,
"numInferenceSteps": 23,
"additionalLoraScale": 1.02
}
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}")
Explanation of the Code
In this code snippet, you need to replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and ensure the endpoint is correct. The action ID for generating enhanced images is provided, and the input payload is structured based on the schema requirements. You send a POST request with the input data, and the response is printed in a readable format.
Conclusion
The Bishorahu/Prajwal Cognitive Actions provide a robust solution for developers aiming to enhance image generation processes in their applications. With customizable parameters and the ability to generate high-quality images, these actions open up a world of creative possibilities. Explore these features and consider how they can be integrated into your projects for innovative visual content creation.