Create Stunning Images with neyananava/krnn Cognitive Actions

In the realm of image generation, the neyananava/krnn Cognitive Actions offer developers powerful tools for creating high-resolution images through advanced techniques. With capabilities like customizable prompts, aspect ratios, and model optimizations, these actions allow for dynamic and flexible image creation. In this blog post, we will explore how to leverage the "Generate High-Resolution Images" action to enhance your applications with stunning visuals.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- API Key: You will need an API key to access the Cognitive Actions platform. This key should be included in your request headers for authentication.
- Setup: Familiarity with making HTTP requests and handling JSON data will be beneficial for implementing the examples provided.
Conceptually, the API key can be passed in the headers of your requests to authenticate your access to the Cognitive Actions.
Cognitive Actions Overview
Generate High-Resolution Images
The Generate High-Resolution Images action allows you to create stunning images using advanced image-to-image or inpainting techniques. It offers a range of customizable properties such as aspect ratio, image dimensions, and prompt strength, enabling you to fine-tune the output to your specific needs.
Input
The action requires a JSON payload with the following schema:
- Required Fields:
prompt: A detailed description of the image to be generated.
- Optional Fields:
mask: Image mask for inpainting.seed: An integer for reproducible generation.image: Input image for transformation.model: Choose between"dev"and"schnell"for different processing speeds and details.widthandheight: Dimensions of the generated image (only applicable when using a custom aspect ratio).aspectRatio: Set the aspect ratio for the image.imageFormat: Format for the output image (e.g.,webp,jpg,png).imageQuality: Quality level for the output image.guidanceScale: Controls the diffusion process for realism.enableFastMode: Enable or disable speed-optimized model usage.numberOfOutputs: Number of images to generate (up to 4).- Additional fields for advanced users, including LoRA weights and safety checks.
Example Input:
{
"model": "dev",
"prompt": "beautiful light skinned KRNN, KRNN is extremely wealthy. KRNN sitting in very expensive restaurant, wearing black turtleneck. picture taken by her boyfriend in the living room, art and vases, tall ceiling in background, during the day with natural daylight, taken with using a Canon EOS R camera with bright flash, a 50mm f/1.8 lens, f/2.2 aperture, shutter speed 1/200s, ISO 100 and natural light, Full Body, Hyper-Realistic Photography, Hyperdetail, Ultrahd, 10K quality resolution, 10D, crisp clarity, 100% sharpness, ultrahigh definition, cinematic lighting, and intricate texture detailing, natural rough hyper-realistic skin texture, pores and on face visible, no glow on face, matte face, natural soft eyebrows, .jpeg quality, not edited, hyper-realistic lips, no glow lips, emphasizing realistic shadows and reflections. The photo feels unedited, like true user-generated content, with a raw, authentic feel. The result is a genuine and believable real-camera effect. The models have natural, soft eyebrows and matte, hydrated lips (no shine or gloss). real skin not wax skin, no eyebags, matte chin, including visible pores, subtle fine lines, vellus hair, and matte, non-reflective areas for an unedited, lifelike finish. Avoid overly smooth or waxy skin; the texture should replicate professional, high-resolution photography with natural imperfections. Maintain raw, untouched .jpeg quality, avoiding any artificial edits or over-processing. 10K resolution with cinematic lighting enhances realism, white teeth, naturally raised and arched eyebrows, Everything is rendered without any distortion or alteration. with every detail perfectly preserved. Render details without any artistic interpretation, crisp clarity",
"aspectRatio": "1:1",
"imageFormat": "webp",
"imageQuality": 80,
"guidanceScale": 3,
"enableFastMode": false,
"numberOfOutputs": 1,
"promptInfluenceLevel": 0.8,
"additionalLoraStrength": 1,
"numberOfInferenceSteps": 28,
"loraApplicationStrength": 1
}
Output
The action typically returns a URL pointing to the generated image. Here’s an example of what you might receive:
Example Output:
[
"https://assets.cognitiveactions.com/invocations/3f847319-856f-4f8a-bbf0-3a4b3dee3edc/951b7b91-3def-4a6e-8601-d45d99d2daeb.webp"
]
Conceptual Usage Example (Python)
Here’s how you might call the Generate High-Resolution Images 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 = "d07221f8-a342-4381-84b5-de7a35577d4c" # Action ID for Generate High-Resolution Images
# Construct the input payload based on the action's requirements
payload = {
"model": "dev",
"prompt": "beautiful light skinned KRNN, KRNN is extremely wealthy. KRNN sitting in very expensive restaurant, wearing black turtleneck...",
"aspectRatio": "1:1",
"imageFormat": "webp",
"imageQuality": 80,
"guidanceScale": 3,
"enableFastMode": False,
"numberOfOutputs": 1,
"promptInfluenceLevel": 0.8,
"additionalLoraStrength": 1,
"numberOfInferenceSteps": 28,
"loraApplicationStrength": 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, you will replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key and Cognitive Actions endpoint with the correct URL. This example illustrates how to structure the input payload, where you specify the action ID and required parameters.
Conclusion
The neyananava/krnn Cognitive Action for generating high-resolution images provides developers with an innovative way to create stunning visuals tailored to specific descriptions. By leveraging customizable parameters, you can enhance your applications with beautifully rendered images that capture the essence of your prompts.
As you explore the capabilities of these Cognitive Actions, consider experimenting with different prompts and settings to unlock even more creative possibilities in your projects!