Transform Your Images with the SDXL-Vivian Cognitive Actions

24 Apr 2025
Transform Your Images with the SDXL-Vivian Cognitive Actions

In the realm of digital content creation, the mattrothenberg/sdxl-vivian Cognitive Actions offer dynamic capabilities to enhance and generate images efficiently. These pre-built actions streamline the image generation process, allowing developers to focus on creativity rather than the intricacies of image processing. With features such as inpainting, customizable prompts, and various refinement techniques, these actions can significantly enrich your applications.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Familiarity with making HTTP requests and handling JSON payloads.

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

Cognitive Actions Overview

Generate Inpainted Image

The Generate Inpainted Image action allows developers to create images by filling in designated areas based on a mask. This action supports various parameters for customizing the output, including image dimensions, prompt strength, and the option to apply watermarking.

Input

The input schema for this action consists of several fields that can be tailored to suit your needs. Here’s a breakdown of the required and optional fields:

  • mask (string, required): URI of the input mask. Black areas are preserved, while white areas are inpainted.
  • image (string, required): URI of the input image for img2img or inpaint mode.
  • prompt (string, default: "An astronaut riding a rainbow unicorn"): Descriptive text for the desired output.
  • width (integer, default: 1024): Width of the output image in pixels.
  • height (integer, default: 1024): Height of the output image in pixels.
  • refine (string, default: "no_refiner"): Selects the refinement method.
  • guidanceScale (number, default: 7.5): Intensity of classifier-free guidance.
  • applyWatermark (boolean, default: true): Applies a watermark to the output image.
  • negativePrompt (string, default: ""): Specifies elements to exclude from the generated image.
  • promptStrength (number, default: 0.8): Strength of the prompt effect.
  • numberOfOutputs (integer, default: 1): Number of images to generate, ranging from 1 to 4.
  • numberOfInferenceSteps (integer, default: 50): Total number of denoising steps for image generation.

Here’s an example JSON payload for the action:

{
  "width": 1024,
  "height": 1024,
  "prompt": "A street portrait of a hot dog vendor in the style of TOK",
  "refine": "no_refiner",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 50
}

Output

Upon successful execution, this action returns a URI link to the generated image. Here’s an example of what you might receive:

[
  "https://assets.cognitiveactions.com/invocations/9b8a5266-77a8-4f82-ad33-ad5ebba87b72/e473f639-5c53-4879-898a-ad0336c4996c.png"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Inpainted 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 = "080d0885-d3db-4770-9cf4-d235e8a63842"  # Action ID for Generate Inpainted Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "A street portrait of a hot dog vendor in the style of TOK",
    "refine": "no_refiner",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 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 example, replace the YOUR_COGNITIVE_ACTIONS_API_KEY and COGNITIVE_ACTIONS_EXECUTE_URL with your actual credentials and endpoint. The payload variable contains the structured input needed for the action.

Conclusion

The mattrothenberg/sdxl-vivian Cognitive Actions provide powerful tools for image generation and manipulation, enabling developers to create unique visual content with ease. By leveraging the Generate Inpainted Image action, you can enhance your applications with custom-generated images tailored to your specifications. Explore further use cases and combine these actions to unlock even more creative potential in your projects!