Create Stunning Images with the hunterkamerman/sdxl-hope Cognitive Actions

25 Apr 2025
Create Stunning Images with the hunterkamerman/sdxl-hope Cognitive Actions

The hunterkamerman/sdxl-hope API offers developers an innovative way to generate images inspired by the iconic Obama hope poster, utilizing a fine-tuned SDXL LoRA model. With pre-built Cognitive Actions, you can create tailored outputs by customizing various settings such as image dimensions, prompt strength, and refinement styles. This article will guide you through the process of integrating this powerful image generation capability into your applications.

Prerequisites

Before you begin, ensure you have access to the Cognitive Actions platform. You'll need an API key to authenticate your requests, which you can pass in the headers of your API calls. Make sure to set up your environment for making HTTP requests, such as using the requests library in Python.

Cognitive Actions Overview

Generate Hope Style Image

The Generate Hope Style Image action allows you to create images with a fine-tuned SDXL LoRA model, perfect for generating visually appealing content based on user-defined prompts.

Input

The input for this action is structured as follows:

  • mask (optional): URI for the input mask in inpaint mode.
  • seed (optional): Integer for randomization.
  • image (optional): URI for the input image in img2img or inpaint mode.
  • width (default: 1024): Width of the output image in pixels.
  • height (default: 1024): Height of the output image in pixels.
  • prompt (default: "An astronaut riding a rainbow unicorn"): Text prompt guiding the image generation.
  • refine (default: "no_refiner"): Select the refinement style.
  • scheduler (default: "K_EULER"): Scheduler type for the image generation process.
  • guidanceScale (default: 7.5): Adjusts the influence of the guidance model.
  • applyWatermark (default: true): If true, applies a watermark to the output image.
  • negativePrompt (default: ""): A prompt indicating aspects to avoid in the image.
  • promptStrength (default: 0.8): Strength of the prompt when using img2img or inpaint.
  • numberOfOutputs (default: 1): Specifies how many images to generate (up to 4).
  • highNoiseFraction (default: 0.8): Fraction of noise when using 'expert_ensemble_refiner'.
  • loraAdditiveScale (default: 0.6): Adjusts the LoRA additive scale.
  • inferenceStepsCount (default: 50): Number of steps used in the denoising process.
  • disableSafetyChecker (default: false): Disables the safety checker for generated images.

Here’s an example of the JSON payload needed for this action:

{
  "width": 1024,
  "height": 1024,
  "prompt": "TOK hope style images red white and blue, kim kardashian portrait",
  "refine": "no_refiner",
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "loraAdditiveScale": 0.6,
  "inferenceStepsCount": 50
}

Output

The action typically returns a URL pointing to the generated image. Here’s an example of the output you might receive:

[
  "https://assets.cognitiveactions.com/invocations/f06aa9b7-6f8c-45ef-861e-ec59f79ae1f2/2d28b8ca-66bc-4965-824a-4f8cc1a92935.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call this action:

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 = "ddbafaa8-a0d8-4225-96cd-56944b6cf2bc"  # Action ID for Generate Hope Style Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "TOK hope style images red white and blue, kim kardashian portrait",
    "refine": "no_refiner",
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "highNoiseFraction": 0.8,
    "loraAdditiveScale": 0.6,
    "inferenceStepsCount": 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 the placeholders with your API key and ensure the endpoint URL is correct. The payload variable is structured according to the input schema of the action.

Conclusion

The hunterkamerman/sdxl-hope Cognitive Actions empower developers to easily create stunning images tailored to specific requirements. By utilizing the diverse input parameters, you can experiment with various styles and outputs, making it a versatile tool for your applications. As a next step, consider integrating this action into your image processing pipeline or exploring more complex prompts to further enhance your creations. Happy coding!