Generate Stunning AI-Enhanced Images with the SD XL NYACOMP Cognitive Actions

21 Apr 2025
Generate Stunning AI-Enhanced Images with the SD XL NYACOMP Cognitive Actions

In the realm of digital creativity, the SD XL NYACOMP Cognitive Actions provide an exciting opportunity to generate and refine images using advanced AI techniques. This set of actions supports various functionalities such as inpainting, image-to-image transformations, and guided image generation through descriptive prompts. By leveraging these pre-built actions, developers can quickly integrate powerful image generation capabilities into their applications, enhancing user experiences and creativity.

Prerequisites

To get started with the SD XL NYACOMP Cognitive Actions, you'll need an API key for authentication. This key should be passed in the headers of your requests to ensure secure access to the service. You may also want to familiarize yourself with how to send JSON payloads, as the inputs for the actions will be structured in this format.

Cognitive Actions Overview

Generate AI-Enhanced Images with Masking

The Generate AI-Enhanced Images with Masking action allows you to create and refine images using the SD XL NYACOMP model. This action supports various image processing techniques such as inpainting, image-to-image transformations, and guided image generation through user-defined prompts.

Input

The input for this action is structured as follows:

{
  "mask": "uri_to_mask_image",              // Optional: A URI to the input mask for inpainting
  "seed": 0,                                 // Optional: Random seed for generation (leave blank for random)
  "image": "uri_to_input_image",             // Required: A URI to the input image
  "width": 1024,                             // Optional: Output image width in pixels (default is 1024)
  "height": 1024,                            // Optional: Output image height in pixels (default is 1024)
  "prompt": "nyancat nvidia nyacomp gpu weight compression",  // Required: Descriptive prompt for image generation
  "loraScale": 0.6,                         // Optional: Scale factor for LoRA (0 to 1)
  "numOutputs": 1,                          // Optional: Number of images to generate (1 to 4)
  "refineSteps": 50,                        // Optional: Number of refinement steps
  "loadSettings": "{\"RUN\": \"0\"}",      // Optional: Environment variables in JSON format
  "scheduleType": "K_EULER",                // Optional: Type of scheduler for denoising
  "guidanceScale": 7.5,                     // Optional: Guidance strength scale (1 to 50)
  "applyWatermark": true,                   // Optional: Whether to apply a watermark
  "negativePrompt": "",                      // Optional: Prompt aspects to avoid
  "promptStrength": 0.8,                     // Optional: Intensity of prompt influence (0 to 1)
  "refinementStyle": "no_refiner",          // Optional: Style of refinement
  "highNoiseFraction": 0.8,                 // Optional: Noise fraction for refinement
  "numInferenceSteps": 50,                  // Optional: Steps of denoising to apply (1 to 500)
  "disableSafetyChecker": false              // Optional: Disable safety checker
}

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "nyancat nvidia nyacomp gpu weight compression",
  "loraScale": 0.6,
  "numOutputs": 1,
  "loadSettings": "{\"RUN\": \"0\"}",
  "scheduleType": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "refinementStyle": "no_refiner",
  "highNoiseFraction": 0.8,
  "numInferenceSteps": 50
}

Output

The output of the action is a URI to the generated image. Here’s an example of what you can expect:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/3000eb2c-a7d3-4c40-bae4-0788998e947d/7129ea60-3f91-4c56-8305-9e44cf2e0b63.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet illustrating how to call the SD XL NYACOMP Cognitive Actions execution endpoint. This example focuses on structuring the input JSON payload correctly.

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 = "8e8dd54f-6a09-4889-927b-3f8627859999"  # Action ID for Generate AI-Enhanced Images with Masking

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "nyancat nvidia nyacomp gpu weight compression",
    "loraScale": 0.6,
    "numOutputs": 1,
    "loadSettings": "{\"RUN\": \"0\"}",
    "scheduleType": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "refinementStyle": "no_refiner",
    "highNoiseFraction": 0.8,
    "numInferenceSteps": 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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The code constructs the input payload based on the action's requirements and sends a POST request to the hypothetical endpoint.

Conclusion

The SD XL NYACOMP Cognitive Actions provide developers with powerful tools to generate stunning images through various advanced techniques. By integrating these actions, you can enhance your applications and offer users unique visual experiences. Consider exploring potential use cases such as art generation, content creation, or even game development to fully leverage the capabilities of these Cognitive Actions. Happy coding!