Create Unique Characters with the Painter Detective Cognitive Actions

21 Apr 2025
Create Unique Characters with the Painter Detective Cognitive Actions

In the world of game design and art, the ability to generate unique characters is invaluable. The ugleh/flux-dev-lora-painterdetective API provides a powerful set of Cognitive Actions that leverage the Flux LoRA model to create characters inspired by the art style of the board game Painter Detective. These pre-built actions simplify the process of character creation, allowing developers to focus on creativity rather than the complexities of image generation.

Prerequisites

Before diving into the use of the Painter Detective Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of making HTTP requests and handling JSON data.
  • Familiarity with Python will be beneficial for the coding examples provided.

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

Cognitive Actions Overview

Generate Painter Detective Style Characters

This action generates characters based on the art style of the board game Painter Detective. It offers options to optimize for speed and detail, making it suitable for various applications.

  • Category: Image Generation

Input

The action requires a structured JSON input, detailed as follows:

  • Required Fields:
    • prompt: A descriptive text prompt guiding image generation.
  • Optional Fields:
    • mask: URI for an image mask used in image inpainting mode.
    • seed: Integer for reproducible outputs.
    • image: URI for an input image for image-to-image or inpainting mode.
    • model: Choose between "dev" (more detailed) and "schnell" (faster).
    • width: Width of the generated image (when aspect ratio is custom).
    • height: Height of the generated image (when aspect ratio is custom).
    • goFast: Enable faster predictions.
    • aspectRatio: Preset or custom aspect ratio.
    • outputFormat: Desired format for output images (webp, jpg, png).
    • guidanceScale: Scale for the diffusion process.
    • outputQuality: Quality of output images on a scale from 0 to 100.
    • numberOfOutputs: Number of outputs to generate.
    • numberOfInferenceSteps: Number of denoising steps.

Here’s an example input JSON that illustrates the structure:

{
  "model": "dev",
  "width": 512,
  "height": 512,
  "prompt": "man, brown hair, balding, eyes closed, smile, scar on left cheek, long ears, orange prison jumpsuit, dots for nose, round head, light complexion",
  "loraScale": 1,
  "aspectRatio": "1:1",
  "outputFormat": "png",
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "numberOfOutputs": 4,
  "additionalLoraScale": 0.8,
  "numberOfInferenceSteps": 28
}

Output

The output of this action is typically an array of URLs linking to the generated images. Here’s an example of what you might expect:

[
  "https://assets.cognitiveactions.com/invocations/f715b66d-3fbb-49c8-b991-35f3504d0b2d/b10299ba-c1c0-4eba-a6ba-e0ec1a6b6550.png",
  "https://assets.cognitiveactions.com/invocations/f715b66d-3fbb-49c8-b991-35f3504d0b2d/140822e7-e7a1-45fb-8b91-4b15b2ce1452.png",
  "https://assets.cognitiveactions.com/invocations/f715b66d-3fbb-49c8-b991-35f3504d0b2d/117b8217-a46b-4a87-8a0d-a6aeb7108a87.png",
  "https://assets.cognitiveactions.com/invocations/f715b66d-3fbb-49c8-b991-35f3504d0b2d/d17b6e6c-07aa-4e78-b139-4004ab36f393.png"
]

Conceptual Usage Example (Python)

Here’s how you might call this Cognitive 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 = "2bf853d3-12dd-4537-8804-0b583a7937c7"  # Action ID for Generate Painter Detective Style Characters

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 512,
    "height": 512,
    "prompt": "man, brown hair, balding, eyes closed, smile, scar on left cheek, long ears, orange prison jumpsuit, dots for nose, round head, light complexion",
    "loraScale": 1,
    "aspectRatio": "1:1",
    "outputFormat": "png",
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "numberOfOutputs": 4,
    "additionalLoraScale": 0.8,
    "numberOfInferenceSteps": 28
}

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, replace the COGNITIVE_ACTIONS_API_KEY with your actual API key. The structure of the request includes the action ID and the input payload that matches the requirements of the Cognitive Action.

Conclusion

The ugleh/flux-dev-lora-painterdetective Cognitive Actions empower developers to create unique characters effortlessly, enhancing the creative process in game development and digital art. By leveraging these pre-built actions, you can quickly generate high-quality images that reflect specific styles and concepts.

Explore these capabilities in your applications, and consider combining multiple actions for even more dynamic results! Happy coding!