Create Stunning Art with the xrunda/tiaoseyou2 Cognitive Action

23 Apr 2025
Create Stunning Art with the xrunda/tiaoseyou2 Cognitive Action

In the world of digital creativity, the ability to generate art using advanced algorithms has become increasingly accessible. The xrunda/tiaoseyou2 API offers a powerful Cognitive Action that allows developers to create stunning oil paintings in the unique style of artist Chen Shudan. With options for image modifications, custom prompts, and more, this action opens the door for innovative applications in art generation, design, and beyond.

Prerequisites

Before diving into the integration of the xrunda/tiaoseyou2 Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • A basic understanding of JSON for structuring input and output data.
  • Familiarity with making HTTP requests in your preferred programming language (for example, Python).

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Chen Shudan Style Painting

The Generate Chen Shudan Style Painting action allows you to create oil paintings that reflect the distinct artistic style of Chen Shudan. Users can provide prompts, adjust image properties, and refine results to produce unique artworks.

Input

The input schema for this action is quite detailed. Here’s a breakdown of the required and optional fields:

  • prompt (string): A text prompt to guide the image generation (e.g., "a oil painting by tiaoseyou Two people watching the sunset").
  • width (integer): Width of the output image in pixels (default: 1024).
  • height (integer): Height of the output image in pixels (default: 1024).
  • loraScale (number): A scale factor for LoRA model adjustments (default: 0.6, range: 0 to 1).
  • numOutputs (integer): Number of images to output (default: 1, range: 1 to 4).
  • guidanceScale (number): Adjusts the classifier-free guidance scale (default: 7.5, range: 1 to 50).
  • applyWatermark (boolean): Determines if a watermark should be applied (default: true).
  • negativePrompt (string): Elements to exclude from the generated image.
  • promptStrength (number): Strength of the input prompt in img2img or inpainting modes (default: 0.8, range: 0 to 1).
  • refinementStyle (string): Defines the refinement style to use (default: "no_refiner").
  • highNoiseFraction (number): Fraction of noise applied when using the expert ensemble refiner (default: 0.8).
  • numInferenceSteps (integer): Number of steps for denoising the image (default: 50, range: 1 to 500).
  • schedulingAlgorithm (string): Selects the scheduling algorithm used for the inference process (default: "K_EULER").
  • mask (string, optional): URI of the input mask for inpainting.
  • seed (integer, optional): An integer seed for randomness.
  • loraWeights (string, optional): Weights for the LoRA model.
  • refineSteps (integer, optional): Number of refinement steps for the base image refiner.
  • disableSafetyChecker (boolean, optional): Option to disable the safety checker.

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a oil painting by tiaoseyou Two people watching the sunset",
  "loraScale": 0.8,
  "numOutputs": 1,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "refinementStyle": "expert_ensemble_refiner",
  "highNoiseFraction": 0.8,
  "numInferenceSteps": 50,
  "schedulingAlgorithm": "K_EULER"
}

Output

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

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/9e9a04e6-6ac0-44b2-87e8-83d2c458149b/a797c5ed-6a3f-41ae-a98b-cba1a843c763.png"
]

Conceptual Usage Example (Python)

Here’s how a developer might call the Cognitive Actions execution endpoint 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 = "78cbda57-3aaa-41f8-b8b3-6203f8ae0a63"  # Action ID for Generate Chen Shudan Style Painting

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a oil painting by tiaoseyou Two people watching the sunset",
    "loraScale": 0.8,
    "numOutputs": 1,
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "",
    "promptStrength": 0.8,
    "refinementStyle": "expert_ensemble_refiner",
    "highNoiseFraction": 0.8,
    "numInferenceSteps": 50,
    "schedulingAlgorithm": "K_EULER"
}

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 COGNITIVE_ACTIONS_API_KEY and the action ID with your actual API key and the ID for the Generate Chen Shudan Style Painting action. The input payload is structured according to the action's requirements, and the endpoint URL is hypothetical.

Conclusion

The xrunda/tiaoseyou2 Cognitive Action for generating Chen Shudan style paintings offers a versatile tool for developers looking to incorporate artistic image generation into their applications. By leveraging customizable prompts and parameters, you can create unique artworks tailored to your needs. Start exploring the possibilities today and unleash your creativity!