Create Stunning Images with Denise's Enhanced Image Generation

In the world of digital creativity, the need for high-quality images is paramount. Enter "Denise," a powerful tool designed to streamline the image generation process through advanced Cognitive Actions. With Denise, developers can generate enhanced images that meet a variety of specifications and artistic visions, all while saving time and effort. This service supports inpainting and image-to-image techniques, allowing for a high degree of customization in terms of mask, seed, size, and output format.
Imagine being able to create stunning visuals for your applications or marketing materials without the need for extensive graphic design skills. Whether you're looking to enhance existing images or generate entirely new visuals based on specific prompts, Denise empowers developers to produce professional-grade images with just a few API calls. This capability can be especially beneficial for industries such as e-commerce, social media, and content creation, where compelling visuals are key to engaging audiences.
Prerequisites
To get started using Denise, you'll need a Cognitive Actions API key and a basic understanding of how to make API calls.
Generate Enhanced Images
The "Generate Enhanced Images" action is at the core of Denise's capabilities. This action allows you to create high-quality images using advanced techniques tailored to your needs.
Purpose
This action is designed to solve the problem of generating visually appealing images quickly and efficiently. By utilizing inpainting or image-to-image techniques, developers can customize various aspects of the image generation process, ensuring that the output aligns perfectly with their creative vision.
Input Requirements
To use this action, the following inputs are required:
- Prompt: A string that serves as the basis for the generated image.
- Image (optional): An input image for inpainting or image-to-image transformations.
- Model: Choose between "dev" for high-quality results or "schnell" for faster generation.
- Aspect Ratio: Define the aspect ratio for the generated image (e.g., 1:1, 16:9).
- Output Format: Specify the desired output format (e.g., webp, jpg, png).
- Additional parameters include seed, number of outputs, prompt intensity, and guidance scale, among others.
Expected Output
The output will be a high-quality image generated based on the provided prompt and parameters. For example, you might receive a link to an image like this:
https://assets.cognitiveactions.com/invocations/96baab18-4502-459c-9913-b226fe084e41/a56b8df2-f755-4acc-a628-f81b18527268.webp
Use Cases for this Specific Action
- E-commerce: Generate product images that stand out in online listings.
- Marketing: Create eye-catching visuals for social media campaigns or advertisements.
- Content Creation: Enhance blog posts or articles with relevant and attractive images.
- Game Development: Design unique characters or environments based on specific artistic prompts.
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 = "6a5d2ddb-001b-4098-8b2b-36f7e73a9a4c" # Action ID for: Generate Enhanced Images
# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
"image": "https://replicate.delivery/pbxt/LtQ9UdywlNMCyzez9ynSdhAVOWWtzCAGY7qojJ8asWGsVddQ/f2b7daf02c7b869d665fc233ea75d1c3.jpg",
"model": "dev",
"prompt": "denisepetrim/denise:07b8e3c3213db1b1a4cfe8373c6ea558c58446a1313774be49d375faf4dcee54",
"loraWeightScale": 1,
"numberOfOutputs": 1,
"promptIntensity": 0.8,
"imageAspectRatio": "1:1",
"imageOutputFormat": "webp",
"imageOutputQuality": 90,
"additionalLoraScale": 1,
"guidanceWeightScale": 3.5,
"numberOfInferenceSteps": 28
}
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
Denise offers developers an invaluable tool for creating stunning images with ease and precision. By leveraging the "Generate Enhanced Images" action, you can streamline your creative processes and produce high-quality visuals tailored to your specific needs. Whether for personal projects or professional applications, the possibilities are endless. To get started, simply integrate the API into your workflow and explore the full range of customization options available. Happy creating!