Create Stunning DaVinci-Style Images with the cbh123/sdxl-davinci Cognitive Actions

24 Apr 2025
Create Stunning DaVinci-Style Images with the cbh123/sdxl-davinci Cognitive Actions

In the world of AI-driven creativity, the cbh123/sdxl-davinci spec provides developers with powerful Cognitive Actions to generate images inspired by the artistic mastery of Leonardo Da Vinci. These actions leverage a specialized model fine-tuned on Da Vinci's drawings, allowing developers to produce professional-quality images by simply providing prompts and customizing various settings. Whether you're looking to enhance your applications with unique visuals or automate creative tasks, these pre-built actions are designed to streamline the process.

Prerequisites

Before diving into the Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Basic familiarity with JSON structure and making HTTP requests.

Authentication typically involves passing your API key in the request headers, ensuring secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate DaVinci Style Image

Purpose: This action allows you to create images that capture the essence of Da Vinci's artistic style using the SDXL model. You can customize the output through prompts and various settings, making it suitable for generating unique artwork.

Category: Image Generation

Input

The input schema for this action includes several fields, allowing for extensive customization. Below are the required and optional parameters:

  • prompt (string): Describes the desired image content (e.g., "a drawing of a robot in the style of TOK").
  • width (integer): Width of the output image in pixels (default: 1024).
  • height (integer): Height of the output image in pixels (default: 1024).
  • refine (string): Style for refining the image (options: "no_refiner", "expert_ensemble_refiner", "base_image_refiner").
  • loraScale (number): LoRA additive scale (range: 0 to 1, default: 0.6).
  • scheduler (string): Denoising scheduler to use (default: "K_EULER").
  • guidanceScale (number): Scale for classifier-free guidance (range: 1 to 50, default: 7.5).
  • applyWatermark (boolean): Indicates if a watermark should be applied (default: true).
  • promptStrength (number): Strength of the prompt when using img2img or inpaint mode (range: 0 to 1, default: 0.8).
  • numberOfOutputs (integer): Number of generated output images (range: 1 to 4, default: 1).
  • numberOfInferenceSteps (integer): Total number of denoising steps performed (range: 1 to 500, default: 50).
  • highNoiseFraction (number): Fraction of noise to use for expert ensemble refinement (range: 0 to 1, default: 0.8).

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a drawing of a robot in the style of TOK",
  "refine": "no_refiner",
  "loraScale": 0.6,
  "scheduler": "K_EULER",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "numberOfInferenceSteps": 50
}

Output

The output of this action typically includes the URI of the generated image. Here's an example of what you might receive:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/1083a530-b120-4808-aed6-aaaed7a466b9/c9bc38fa-da11-418f-8049-3388b4a64988.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual example of how to call this action using Python. Replace the action ID and input payload with the specifics for your use case.

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 = "6972f131-f32f-420e-8435-2b3c00cd49ee"  # Action ID for Generate DaVinci Style Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a drawing of a robot in the style of TOK",
    "refine": "no_refiner",
    "loraScale": 0.6,
    "scheduler": "K_EULER",
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "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 code snippet, the action ID and input payload are structured correctly for invoking the Cognitive Actions execution endpoint. Note that the URL and request structure should be adjusted based on the actual API specifications.

Conclusion

The cbh123/sdxl-davinci Cognitive Actions open up a world of creative possibilities by allowing developers to generate stunning images inspired by Da Vinci's style with just a few lines of code. By utilizing these actions, you can enhance your applications with unique visuals tailored to your specific needs. Explore the potential of AI-driven art generation and consider the various use cases from automating creative tasks to enriching user experiences.