Create Stunning Images with the fofr/sdxl-color Cognitive Actions

22 Apr 2025
Create Stunning Images with the fofr/sdxl-color Cognitive Actions

In the world of image generation, the fofr/sdxl-color spec offers developers a robust set of tools to create visually appealing images using advanced techniques such as img2img processing and inpainting. By leveraging the power of pre-built Cognitive Actions, developers can enhance their applications with features that prioritize speed and quality, making it easier to generate solid color images tailored to specific requirements.

Prerequisites

Before you can start integrating the Cognitive Actions from the fofr/sdxl-color spec, ensure you have the following:

  • API Key: You will need an API key to authenticate your requests. This key should be passed in the headers of your API calls.
  • Basic Setup: Familiarity with making HTTP requests and handling JSON data in your programming environment will be beneficial.

Cognitive Actions Overview

Generate Solid Color Image

The Generate Solid Color Image action allows you to create solid color images using a fine-tuned SDXL model. This action provides enhancements such as img2img processing, inpainting, and classifier-free guidance, all designed to deliver high-quality outputs quickly.

Input

The input for this action consists of a variety of fields that control the image generation process. Below is the schema and an example input payload:

{
  "width": 1024,
  "height": 1024,
  "prompt": "A TOK red living room, sofa",
  "loraScale": 0.6,
  "numOutputs": 4,
  "refineStyle": "expert_ensemble_refiner",
  "guidanceScale": 7.5,
  "highNoiseFrac": 0.8,
  "applyWatermark": false,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "schedulingMethod": "K_EULER",
  "numInferenceSteps": 50
}
  • Width: (integer) Width of the output image in pixels (default: 1024).
  • Height: (integer) Height of the output image in pixels (default: 1024).
  • Prompt: (string) The description to guide the image generation.
  • LoRA Scale: (number) Factor for LoRA, ranging from 0 to 1 (default: 0.6).
  • Num Outputs: (integer) Number of images to generate (default: 1).
  • Refine Style: (string) Selected refinement style (default: "no_refiner").
  • Guidance Scale: (number) Scale for classifier-free guidance (default: 7.5).
  • High Noise Frac: (number) Fraction of noise for refining (default: 0.8).
  • Apply Watermark: (boolean) Whether to apply a watermark (default: true).
  • Negative Prompt: (string) Specify elements to exclude from the generated image.
  • Prompt Strength: (number) How much to influence the prompt in img2img or inpaint mode (default: 0.8).
  • Scheduling Method: (string) Denoising schedule method (default: "K_EULER").
  • Num Inference Steps: (integer) Total denoising iterations (default: 50).

Output

Upon a successful execution of this action, you will receive an array of links to the generated images, similar to the following example output:

[
  "https://assets.cognitiveactions.com/invocations/776a12f5-ae69-454a-ad1b-72b9eaf2e52a/8d4d494c-4f22-4d84-9efa-0eee20fe7c65.png",
  "https://assets.cognitiveactions.com/invocations/776a12f5-ae69-454a-ad1b-72b9eaf2e52a/d33e18b8-7bae-4979-99b1-ba51473f0fcb.png",
  "https://assets.cognitiveactions.com/invocations/776a12f5-ae69-454a-ad1b-72b9eaf2e52a/ad02d8a9-f29e-4c5f-a38c-744a5eb1d827.png",
  "https://assets.cognitiveactions.com/invocations/776a12f5-ae69-454a-ad1b-72b9eaf2e52a/aa4bb725-a067-44bf-9fc5-412c67f46f3b.png"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet to demonstrate how to call the Generate Solid Color Image action using a hypothetical Cognitive Actions execution endpoint:

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 = "5a4428c5-d670-4ec7-92b6-d15f126a4a7f" # Action ID for Generate Solid Color Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "A TOK red living room, sofa",
    "loraScale": 0.6,
    "numOutputs": 4,
    "refineStyle": "expert_ensemble_refiner",
    "guidanceScale": 7.5,
    "highNoiseFrac": 0.8,
    "applyWatermark": False,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "schedulingMethod": "K_EULER",
    "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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID for the Generate Solid Color Image is used to specify which action you want to execute, and the input payload is structured according to the action's requirements.

Conclusion

The fofr/sdxl-color Cognitive Actions provide a powerful way for developers to create high-quality images tailored to their specifications. By utilizing the Generate Solid Color Image action, you can effortlessly integrate advanced image generation capabilities into your applications. Explore potential use cases, experiment with different parameters, and enhance your projects with stunning visuals!