Create Custom Christmas Sweater Images with the fofr/sdxl-xmas-sweater Cognitive Actions

24 Apr 2025
Create Custom Christmas Sweater Images with the fofr/sdxl-xmas-sweater Cognitive Actions

The fofr/sdxl-xmas-sweater API provides a powerful Cognitive Action that allows developers to generate unique images of Christmas sweaters using a fine-tuned Stable Diffusion XL (SDXL) model. By leveraging this action, you can create visually appealing sweater designs with various customization options, making it perfect for holiday-themed applications, e-commerce platforms, or creative projects.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic understanding of JSON structure, as the input and output will be in JSON format.

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

Cognitive Actions Overview

Generate Xmas Sweater Image

The Generate Xmas Sweater Image action allows you to create images of Christmas sweaters with adjustable features like width, height, and style. You can also refine the styles and control the influence of your prompts to achieve the desired output.

Category: Image Generation

Input

The input for this action is defined by the following schema:

  • mask (optional): URI of the input mask for inpainting. Black areas remain unchanged, while white areas will be inpainted.
  • seed (optional): Specify a random seed for reproducibility. Leave blank to randomize.
  • image (optional): URI of the input image for image-to-image translation or inpainting.
  • width (optional): Width of the output image in pixels (default: 1024).
  • height (optional): Height of the output image in pixels (default: 1024).
  • prompt (required): Text prompt that influences the image generation process (default: "An astronaut riding a rainbow unicorn").
  • loraScale (optional): Scale factor for LoRA adjustment (default: 0.6).
  • scheduler (optional): Algorithm used for scheduling denoising steps (default: "K_EULER").
  • numOutputs (optional): Number of output images (default: 1, range: 1-4).
  • refineStyle (optional): Defines the mode for refinement (default: "no_refiner").
  • guidanceScale (optional): Classifier-free guidance scale (default: 7.5).
  • highNoiseFrac (optional): Fraction of noise applied during refinement (default: 0.8).
  • applyWatermark (optional): Toggle to apply a watermark (default: true).
  • negativePrompt (optional): Text prompt to be avoided during image generation.
  • promptStrength (optional): Strength of the prompt effect (default: 0.8).
  • numInferenceSteps (optional): Total number of denoising steps (default: 50, range: 1-500).
  • disableSafetyChecker (optional): Disables the safety checker for generated content (default: false).

Example Input:

{
  "width": 768,
  "height": 768,
  "prompt": "A photo of a TOK sweater, Christmas tree",
  "loraScale": 0.6,
  "scheduler": "K_EULER",
  "numOutputs": 1,
  "refineStyle": "expert_ensemble_refiner",
  "guidanceScale": 7.5,
  "highNoiseFrac": 0.9,
  "applyWatermark": false,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numInferenceSteps": 30
}

Output

The output will typically consist of a URL linking to the generated Christmas sweater image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/b702db28-77b8-4c08-b6fa-f4fd3337b665/d6d238dc-246b-44df-82a6-51896783e562.png"
]

Conceptual Usage Example (Python)

Here’s how you could call the Generate Xmas Sweater 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 = "df3c9378-0e55-430a-add2-345cb35b1bd3"  # Action ID for Generate Xmas Sweater Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 768,
    "height": 768,
    "prompt": "A photo of a TOK sweater, Christmas tree",
    "loraScale": 0.6,
    "scheduler": "K_EULER",
    "numOutputs": 1,
    "refineStyle": "expert_ensemble_refiner",
    "guidanceScale": 7.5,
    "highNoiseFrac": 0.9,
    "applyWatermark": False,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "numInferenceSteps": 30
}

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 replace the API key with your own and structure the input payload to match the requirements of the action. The endpoint URL and request structure provided are illustrative, focusing on how to format and send your request.

Conclusion

The fofr/sdxl-xmas-sweater Cognitive Action offers developers a unique opportunity to create custom Christmas sweater images, enhancing applications with festive designs. By utilizing the various input parameters, you can tailor the output to meet your specific needs, making this action a valuable tool for creative projects during the holiday season. Explore the possibilities and start integrating this action into your applications today!