Generate Stunning Images with kuhibasic10/kuhi1-lora Cognitive Actions

In today's digital landscape, the ability to generate high-quality, customizable images has become an essential feature for many applications. The kuhibasic10/kuhi1-lora spec provides developers with powerful Cognitive Actions designed specifically for image generation. By leveraging these pre-built actions, you can easily create stunning visuals tailored to your application's needs, whether for marketing, design, or creative projects.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for accessing the Cognitive Actions platform.
- Basic knowledge of making HTTP requests and handling JSON data.
- Understanding of how to manage authentication, typically by passing your API key in the request headers.
Cognitive Actions Overview
Generate Custom Image
The Generate Custom Image action allows you to produce high-quality images using customizable parameters. This action supports inpainting, aspect ratio adjustments, and image quality settings, making it incredibly flexible for various use cases.
Input
The input for this action is defined by the CompositeRequest schema, which includes several required and optional fields:
- Required:
prompt(string): A descriptive text that guides the image generation process.
- Optional:
mask(string): URI for an image mask used during inpainting mode.seed(integer): A random seed for reproducible results.image(string): Input image for image-to-image or inpainting mode.model(string): Select fromdev(quality) orschnell(speed).width(integer): Custom width for the generated image.height(integer): Custom height for the generated image.goFast(boolean): Run predictions faster with a speed-optimized model.aspectRatio(string): Select aspect ratio for the image (e.g.,1:1,16:9,custom).numOutputs(integer): Number of images to generate (1-4).outputFormat(string): Desired format for output images (webp,jpg,png).guidanceScale(number): Scale for the diffusion process (0-10).outputQuality(integer): Quality of the output image (0-100).- Additional parameters for LoRA weights and intensities.
Example Input:
{
"model": "dev",
"width": 1155,
"height": 1440,
"prompt": "TOK, Full-body shot of a 38-year-old male insurance broker outside a modern office building. He has short brown hair (no gray hairs) and blue eyes, dressed in his dark navy suit with a briefcase in hand. He is standing near the building entrance, facing the camera, with the cityscape in the background and the sun shining.\n",
"numOutputs": 1,
"aspectRatio": "4:5",
"outputFormat": "jpg",
"guidanceScale": 3.5,
"loraIntensity": 1,
"outputQuality": 100,
"promptStrength": 0.8,
"numInferenceSteps": 28,
"additionalLoraIntensity": 1
}
Output
The action typically returns a list of URLs pointing to the generated images. Here’s an example of what the output might look like:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/6b4e971d-de4d-4a1b-bb9f-ac865d049f20/236fdc09-8119-42e8-b312-559cbed95548.jpg"
]
Conceptual Usage Example (Python)
Here's a conceptual Python code snippet to invoke the Generate Custom Image action. This example demonstrates how to structure the input JSON payload and make a request to the Cognitive Actions 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 = "6797f5b1-caff-4d24-983b-98db74fe2fba" # Action ID for Generate Custom Image
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"width": 1155,
"height": 1440,
"prompt": "TOK, Full-body shot of a 38-year-old male insurance broker outside a modern office building. He has short brown hair (no gray hairs) and blue eyes, dressed in his dark navy suit with a briefcase in hand. He is standing near the building entrance, facing the camera, with the cityscape in the background and the sun shining.\n",
"numOutputs": 1,
"aspectRatio": "4:5",
"outputFormat": "jpg",
"guidanceScale": 3.5,
"loraIntensity": 1,
"outputQuality": 100,
"promptStrength": 0.8,
"numInferenceSteps": 28,
"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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id for the Generate Custom Image action is also included, and the input payload is structured as per the required schema.
Conclusion
The kuhibasic10/kuhi1-lora Cognitive Actions provide developers with a powerful toolset for generating custom images tailored to specific needs. With options for adjusting various parameters, you can create stunning visuals quickly and efficiently. Start integrating these actions into your applications today, and explore the exciting possibilities of image generation!