Create Stunning Images with Krnn's Composite Control

In today's digital landscape, the ability to generate high-quality, hyper-realistic images can significantly enhance your projects, whether you're developing games, creating marketing materials, or designing virtual environments. The Krnn service offers a powerful Cognitive Action called "Generate Image with Composite Control," which allows developers to create stunning visuals tailored to their specific needs. This action simplifies the image generation process, providing flexibility in customization and ensuring quick results without sacrificing quality.
With Krnn, you can generate images using detailed prompts, select from different inference models for speed or quality, and customize parameters like aspect ratio and output quality. Whether you're looking to create realistic portraits, elaborate backgrounds, or product visuals, the potential applications are vast. By harnessing this technology, developers can save time and elevate their creative projects to new heights.
Prerequisites
To get started with Krnn, you will need a Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Image with Composite Control
The "Generate Image with Composite Control" action enables you to create high-resolution images by utilizing composite image generation and inpainting techniques. It addresses the challenge of producing visually appealing images that meet specific requirements, allowing for customization through prompts and various settings.
Input Requirements
The action requires a structured input object known as CompositeRequest, with the following key properties:
- prompt (required): The text prompt that guides the image generation.
- mask: (optional) URI of an image mask for inpainting.
- seed: (optional) Integer seed for reproducibility.
- image: (optional) URI of an input image for transformations.
- width: (optional) Desired width of the image in pixels.
- height: (optional) Desired height of the image in pixels.
- megapixels: (optional) Approximate number of megapixels for the output image.
- outputCount: (optional) Number of images to generate (1 to 4).
- guidanceScale: (optional) Scale influencing the diffusion process.
- enableFastMode: (optional) Toggle for optimized predictions.
- inferenceModel: (optional) Select between 'dev' (detailed) or 'schnell' (fast) models.
- promptStrength: (optional) Influence of the prompt in image transformations.
- imageAspectRatio: (optional) Aspect ratio for the generated image.
- imageOutputFormat: (optional) Format for the output image (webp, jpg, png).
- imageOutputQuality: (optional) Quality of the output image on a scale from 0 to 100.
Expected Output
The output will be a URL to the generated image, which is a high-quality representation based on the provided prompt and settings.
Use Cases for this specific action
- Marketing and Advertising: Create visually compelling images for campaigns, social media, or product showcases to captivate audiences.
- Game Development: Generate realistic characters, environments, or assets that enhance the gaming experience.
- Content Creation: Produce unique images for blogs, articles, or multimedia projects that require high-quality visuals.
- Art and Design: Experiment with creative concepts and styles, allowing artists to visualize their ideas in a hyper-realistic manner.
import requests
import json
# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"
action_id = "f39e7cfa-783e-4256-9639-b51a5aefd6ac" # Action ID for: Generate Image with Composite Control
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"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",
"megapixels": "1",
"outputCount": 1,
"guidanceScale": 3,
"enableFastMode": false,
"inferenceModel": "dev",
"promptStrength": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"mainLoraInfluence": 1,
"imageOutputQuality": 80,
"inferenceStepCount": 28,
"additionalLoraInfluence": 1
}
headers = {
"Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
"Content-Type": "application/json",
# Add any other required headers for the Cognitive Actions API
}
# Prepare the request body for the hypothetical execution endpoint
request_body = {
"action_id": action_id,
"inputs": payload
}
print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")
try:
response = requests.post(
COGNITIVE_ACTIONS_EXECUTE_URL,
headers=headers,
json=request_body
)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
result = response.json()
print("Action executed successfully. Result:")
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 (non-JSON): {e.response.text}")
print("------------------------------------------------")
Conclusion
The "Generate Image with Composite Control" action from Krnn is a powerful tool for developers looking to create high-quality, customized images efficiently. With its various input options and flexibility, this action can be applied across a multitude of domains, from marketing to game development. By leveraging this technology, you can streamline your image generation process and focus on bringing your creative visions to life. Start exploring the capabilities of Krnn today and unlock new possibilities for your projects!