Enhancing Your Images with the robot007/sdxl-demo Cognitive Actions

24 Apr 2025
Enhancing Your Images with the robot007/sdxl-demo Cognitive Actions

In the ever-evolving field of image processing, the ability to enhance images using advanced techniques is invaluable. The robot007/sdxl-demo provides a powerful set of Cognitive Actions that allow developers to generate enhanced images with ease. Utilizing advanced inpainting and img2img techniques, these actions offer a variety of customizable settings, ensuring you can achieve superior quality and tailored results for your applications.

Prerequisites

Before diving into the integration of these Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of JSON and how to structure requests.
  • Familiarity with Python for making API calls.

Authentication typically involves passing your API key in the request headers, allowing secure access to the actions.

Cognitive Actions Overview

Generate Enhanced Image

Description: This action generates enhanced images from input images using advanced inpainting and img2img techniques. It supports various settings to control output, including scheduler types, guidance scales, and prompt strengths, ensuring detailed and customized image generation.

  • Category: Image Enhancement

Input Schema:

The input to this action requires a JSON object with the following properties:

  • mask (string, optional): Input mask for inpaint mode.
  • seed (integer, optional): Seed for random number generation.
  • image (string, required): Input image for transformations.
  • width (integer, default: 1024): Output image width in pixels.
  • height (integer, default: 1024): Output image height in pixels.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Text prompt for the desired output.
  • refine (string, default: "no_refiner"): Specifies the refinement style.
  • scheduler (string, default: "K_EULER"): Algorithm for scheduling steps.
  • customWeights (string, optional): LoRA weights for customization.
  • loraIntensity (number, default: 0.6): Scale factor for LoRA application.
  • applyWatermark (boolean, default: true): Determines if a watermark is applied.
  • negativePrompt (string, optional): Aspects to exclude from the generated image.
  • numberOfOutputs (integer, default: 1): Number of images to produce (1-4).
  • promptIntensity (number, default: 0.8): Strength of the input prompt.
  • refinementSteps (integer, optional): Number of refinement steps for specific refiners.
  • guidanceIntensity (number, default: 7.5): Intensity for classifier-free guidance.
  • highNoiseFraction (number, default: 0.8): Fraction of noise for specific refiners.
  • inferenceStepsCount (integer, default: 50): Number of denoising steps.
  • disableSafetyChecker (boolean, default: false): Disable safety checker for the images.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "boho style, dining room, ",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "loraIntensity": 0.6,
  "applyWatermark": true,
  "negativePrompt": "",
  "numberOfOutputs": 1,
  "promptIntensity": 0.8,
  "guidanceIntensity": 7.5,
  "highNoiseFraction": 0.8,
  "inferenceStepsCount": 50
}

Output:

The action typically returns an array of URLs pointing to the enhanced images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/0fdd041f-9606-4406-88b7-efa285db2260/18adfb50-7c7b-4675-81c5-fcf923276fd9.png"
]

Conceptual Usage Example (Python):

Here’s how you might call the Generate Enhanced Image 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 = "e2725b94-61f5-4868-b244-f1884b5f05d3"  # Action ID for Generate Enhanced Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "boho style, dining room, ",
    "refine": "no_refiner",
    "scheduler": "K_EULER",
    "loraIntensity": 0.6,
    "applyWatermark": True,
    "negativePrompt": "",
    "numberOfOutputs": 1,
    "promptIntensity": 0.8,
    "guidanceIntensity": 7.5,
    "highNoiseFraction": 0.8,
    "inferenceStepsCount": 50
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID is set specific to the Generate Enhanced Image action. The input JSON payload is structured according to the action's requirements.

Conclusion

The robot007/sdxl-demo Cognitive Actions provide a robust solution for enhancing images with customizable options. By utilizing the Generate Enhanced Image action, developers can leverage advanced techniques for image generation, making it easier to produce high-quality content tailored to specific needs. Consider integrating these actions into your applications to unlock new creative possibilities!