Generate Unique Creatures with the deutschla/character-generator Cognitive Actions

23 Apr 2025
Generate Unique Creatures with the deutschla/character-generator Cognitive Actions

The deutschla/character-generator offers powerful Cognitive Actions designed to bring your imaginative creatures to life from simple sketches. By leveraging advanced image generation techniques, these actions allow developers to create unique visual representations based on predefined attributes and user inputs. Integrating these pre-built actions into your applications can save time and enhance creativity, making it easier than ever to generate stunning graphics.

Prerequisites

Before you start using the Cognitive Actions, ensure you have the necessary setup in place:

  • API Key: You will need a valid API key to access the Cognitive Actions platform. This key should be included in the headers of your requests for authentication.
  • Network Access: Make sure your application can connect to the Cognitive Actions API endpoint.

Authentication Concept

Typically, you would pass your API key in the headers of your requests as follows:

Authorization: Bearer YOUR_COGNITIVE_ACTIONS_API_KEY

Cognitive Actions Overview

Create Creature From Sketch

Description: Utilize a model to generate a fully realized creature from a basic sketch, enhancing it with specified attributes and optionally upscaling the image.
Category: Image Generation

Input

The input for this action is structured as follows:

  • seed (optional): Sets the random seed for image generation. Leave blank for varied outcomes.
  • image (required): URI of the input image used for generating output based on the provided prompts.
  • prompt (required): Primary prompt guiding the image generation, describing features to include.
  • invertColors (optional): Inverts colors of the image; recommended for sketches with black strokes on a white background.
  • upscaleImage (optional): Determines if the final output image should be upscaled using ESRGAN.
  • guidanceScale (optional): Adjusts the classifier-free guidance scale. Higher values align images more closely with the text prompt.
  • negativePrompt (optional): Specifies elements to avoid in image generation.
  • additionalPrompt (optional): Additional prompts to influence image generation.
  • removeBackground (optional): Removes the background from the final output image.
  • numInferenceSteps (optional): Specifies the number of denoising steps in image generation.
  • additionalNegativePrompt (optional): Additional prompts for elements to exclude from the image.

Example Input:

{
  "image": "https://replicate.delivery/pbxt/J8duw7Y8vqazMA0ujMPM9j2Tht8YiAH7VZFlIR2wZpUbDfXB/test-scribble.png",
  "prompt": "a duck head, dinosaur leg, tiger claw, bird leg, tentacle arm, dragon body",
  "invertColors": true,
  "upscaleImage": true,
  "guidanceScale": 8,
  "additionalPrompt": "childrens illustration, fantasy creature, solo, single creature, white-background",
  "removeBackground": true,
  "numInferenceSteps": 50,
  "additionalNegativePrompt": "(worst quality, low quality:1.4), shadow, mouth, multiple eyes, signature, watermark, nsfw, plants, human, man, woman, animal, child, boy, girl"
}

Output

The action typically returns a URL to the generated image based on the input specifications.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/6ae60681-592f-4e77-a29d-8e1e2486de03/d2ba503c-1351-4be8-a9ad-c202d203bbad.png"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to call the Create Creature From Sketch 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 = "7d4f2fbf-bc01-4f8d-ac4a-576aa8e7cea2" # Action ID for Create Creature From Sketch

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/J8duw7Y8vqazMA0ujMPM9j2Tht8YiAH7VZFlIR2wZpUbDfXB/test-scribble.png",
    "prompt": "a duck head, dinosaur leg, tiger claw, bird leg, tentacle arm, dragon body",
    "invertColors": True,
    "upscaleImage": True,
    "guidanceScale": 8,
    "additionalPrompt": "childrens illustration, fantasy creature, solo, single creature, white-background",
    "removeBackground": True,
    "numInferenceSteps": 50,
    "additionalNegativePrompt": "(worst quality, low quality:1.4), shadow, mouth, multiple eyes, signature, watermark, nsfw, plants, human, man, woman, animal, child, boy, girl"
}

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, you will need to replace the placeholder for your API key and ensure that the endpoint URL is correctly set. The action ID is specified for the Create Creature From Sketch action, and the input payload is structured as shown.

Conclusion

The deutschla/character-generator Cognitive Action empowers developers to create unique and imaginative creatures from basic sketches with just a few lines of code. With flexibility in prompts and image processing options, you can generate stunning visual content tailored to your needs. Explore this action in your applications to enhance creativity and efficiency in image generation. Happy coding!