Create Stunning Custom Images with Jaewon’s Cognitive Actions

In the world of digital content creation, the ability to generate customized images quickly and efficiently is invaluable. Jaewon offers a powerful Cognitive Action that enables developers to generate images based on detailed text prompts, complete with customizable parameters. This capability not only streamlines the creative process but also enhances the flexibility and precision with which developers can craft visuals tailored to specific needs.
Imagine needing unique illustrations for a marketing campaign, concept art for a video game, or personalized graphics for a social media post. With Jaewon’s image generation capabilities, you can automate these tasks, saving time and effort while ensuring high-quality outputs. The ability to control various settings such as image size, aspect ratio, and model parameters allows for a level of customization that can meet diverse creative requirements.
Prerequisites
Before diving into the action, ensure you have a valid Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Image with Custom Parameters
Purpose
The "Generate Image with Custom Parameters" action allows developers to create customized images based on specific text prompts. Users can adjust parameters such as image size, aspect ratio, and incorporate image masks for inpainting, giving them fine control over the generated outputs. This action is particularly useful for applications that require unique visuals based on user-defined criteria.
Input Requirements
To utilize this action, you must provide a detailed text prompt that describes the desired image. Additionally, you can specify parameters such as:
- Mask: A URI for an image mask in inpainting mode.
- Seed: An integer value for reproducible image generation.
- Image: A URI for an input image used in image-to-image transformations.
- Width and Height: Dimensions of the generated image (if aspect ratio is custom).
- Aspect Ratio: Options include preset ratios or a custom setting.
- Output Format: Choices include webp, jpg, and png.
For a complete list of parameters, refer to the input schema.
Expected Output
The expected output is a URL pointing to the generated image, tailored to the specifications provided in the input. This output can be directly used in applications, websites, or any other platform requiring visual content.
Use Cases for this Specific Action
- Marketing Materials: Generate unique images for advertisements or promotional content that align with brand aesthetics.
- Artistic Projects: Create concept art or illustrations for games, books, or personal projects that require visual storytelling.
- Social Media Content: Quickly produce tailored graphics for posts that resonate with target audiences.
- Prototyping and Design: Develop visual mockups for applications or websites that require specific imagery based on user input.
By leveraging this action, developers can enhance creativity and efficiency in producing high-quality images that meet their specific needs.
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 = "96022af2-4bbd-4f99-92de-49dd868ce729" # Action ID for: Generate Image with Custom Parameters
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"width": 1440,
"height": 1440,
"prompt": "jaewon is a male scientist in his 20s. In a science room full of scientific experiment equipment, Jaewon is wearing a lab coat and conducting a science experiment. \nJaewon is smiling while looking straight ahead in a medium shot showing his upper body. The science room is very spacious and dark, and the scientific instruments shine brightly.\nThe overall atmosphere is antique and luxurious.",
"fastMode": false,
"loraScale": 1,
"megapixels": "1",
"numOutputs": 1,
"aspectRatio": "16:9",
"outputFormat": "png",
"outputQuality": 80,
"inferenceModel": "dev",
"numInferenceSteps": 28,
"additionalLoraScale": 1,
"imagePromptStrength": 0.8,
"diffusionGuidanceScale": 3
}
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
Jaewon’s image generation capabilities empower developers to automate the creation of stunning visuals tailored to specific requirements. With customizable parameters and flexible output options, this Cognitive Action opens up a world of possibilities for various applications, from marketing to artistic endeavors.
To get started, integrate the "Generate Image with Custom Parameters" action into your projects and explore the creative potential it brings. Whether you’re enhancing user experiences or streamlining content creation, Jaewon is here to help you achieve your visual goals.