Create Unique Images with the Ugly Sweater Cognitive Actions

24 Apr 2025
Create Unique Images with the Ugly Sweater Cognitive Actions

In the world of creative applications, generating unique and entertaining visuals can captivate audiences and enhance user experiences. The Ugly Sweater Cognitive Actions provide developers with an innovative API for generating quirky images of ugly sweaters based on customizable text prompts. With options for image refinement and various stylistic choices, these actions allow you to integrate fun and creativity into your applications while saving time on manual design.

Prerequisites

Before you can start using the Ugly Sweater Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of working with JSON and making HTTP requests.
  • An understanding of how to structure your input data to meet the API requirements.

For authentication, you'll typically pass your API key in the request headers when making calls to the Cognitive Actions endpoint.

Cognitive Actions Overview

Generate Ugly Sweater Image

The Generate Ugly Sweater Image action is designed to create an image of an ugly sweater based on a specified text prompt. Developers can customize the image's dimensions, style, and even refine the output through various parameters.

Input

The input for this action requires a JSON object that includes various fields. Below is a breakdown of the input schema along with an example:

  • prompt (string): Text to guide the image generation.
  • width (integer): Desired width of the output image (default is 1024 pixels).
  • height (integer): Desired height of the output image (default is 1024 pixels).
  • refine (string): Specifies the refinement style (e.g., no_refiner).
  • loraScale (number): Scale factor for LoRA models (default is 0.6).
  • scheduler (string): Scheduling method for inference steps (default is K_EULER).
  • guidanceScale (number): Scale factor for classifier-free guidance (default is 7.5).
  • applyWatermark (boolean): Whether to apply a watermark (default is true).
  • negativePrompt (string): Elements to avoid in the image.
  • promptStrength (number): Strength of the image modification (default is 0.8).
  • numberOfOutputs (integer): Number of images to generate (default is 1).
  • numberOfInferenceSteps (integer): Number of denoising steps (default is 50).

Example Input:

{
  "width": 768,
  "height": 1024,
  "prompt": "batman wearing a TOK sweater, superhero",
  "refine": "no_refiner",
  "loraScale": 0.6,
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "deformed, blurry, ugly, ",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "numberOfInferenceSteps": 50
}

Output

Upon successful execution, the action returns a URL to the generated image. The output typically looks like this:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/cd06c67b-adb0-4070-921f-e78d9ff56a86/afae22a5-4c23-4ee4-9459-35ca002865ea.png"
]

Conceptual Usage Example (Python)

Here’s how you might call this action using a conceptual Python script:

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 = "b3dc332a-48cd-4202-8cfe-529664f374d1" # Action ID for Generate Ugly Sweater Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 768,
    "height": 1024,
    "prompt": "batman wearing a TOK sweater, superhero",
    "refine": "no_refiner",
    "loraScale": 0.6,
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": true,
    "negativePrompt": "deformed, blurry, ugly, ",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "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, you'll see how to structure the input JSON payload correctly and send it to the Cognitive Actions endpoint. The endpoint URL and request structure provided are illustrative and should be adapted to your specific implementation.

Conclusion

The Ugly Sweater Cognitive Actions offer a playful and powerful way to generate unique images based on creative prompts. By leveraging this API, developers can easily integrate fun visual content into their applications, enhancing user engagement and overall experience. Consider experimenting with various prompts and parameters to see how diverse the generated images can be!