Transform Your Ideas into Art: Integrating Retro Coloring Book Cognitive Actions

25 Apr 2025
Transform Your Ideas into Art: Integrating Retro Coloring Book Cognitive Actions

Creating unique, vintage-style images has never been easier with the paappraiser/retro-coloring-book Cognitive Actions. This service enables developers to generate retro coloring book images using customizable parameters, allowing for creativity and flexibility in your applications. By leveraging these pre-built actions, you can focus on enhancing user experiences rather than dealing with complex image processing algorithms.

Prerequisites

Before you start integrating the Cognitive Actions, ensure that you have the following:

  • An API key for the Cognitive Actions platform.
  • Familiarity with making HTTP requests in your programming environment.
  • A basic understanding of JSON formatting for structuring your input data.

For authentication, you will typically include your API key in the request headers, which allows secure access to the Cognitive Actions service.

Cognitive Actions Overview

Generate Retro Coloring Book Image

Description: This action allows you to create a vintage-style coloring book image using the TOK model, specifically trained on 1960 coloring books. You can customize inputs such as the mask URI for inpainting, a random seed for reproducibility, and various image parameters including size, prompt text, and refinement style.

Category: Image Generation

Input

The input for this action is structured as follows:

{
  "mask": "string (uri)",
  "seed": "integer (optional)",
  "image": "string (uri)",
  "width": "integer (default: 1024)",
  "height": "integer (default: 1024)",
  "prompt": "string (default: 'An astronaut riding a rainbow unicorn')",
  "loraScale": "number (default: 0.6, range: 0-1)",
  "refineSteps": "integer (optional)",
  "customWeights": "string (optional)",
  "guidanceScale": "number (default: 7.5, range: 1-50)",
  "applyWatermark": "boolean (default: true)",
  "negativePrompt": "string (default: '')",
  "promptStrength": "number (default: 0.8, range: 0-1)",
  "numberOfOutputs": "integer (default: 1, max: 4)",
  "refinementStyle": "string (default: 'no_refiner')",
  "highNoiseFraction": "number (default: 0.8, range: 0-1)",
  "schedulingAlgorithm": "string (default: 'K_EULER')",
  "disableSafetyChecker": "boolean (default: false)",
  "numberOfInferenceSteps": "integer (default: 50, range: 1-500)"
}

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "a picture of TOK a very large and simple evil wizard with no nose. Coloring book vintage minimal lines easy to color",
  "loraScale": 0.6,
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "complex, realistic, color, gradient",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "refinementStyle": "no_refiner",
  "highNoiseFraction": 0.8,
  "schedulingAlgorithm": "K_EULER",
  "numberOfInferenceSteps": 50
}

Output

The output of this action typically returns an array of image URLs generated based on the input parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/31792c8c-7567-49cf-a104-297c8464850c/950c16cd-1824-4edc-a6a2-64258c772e72.png"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate Retro Coloring Book Image 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 = "b6862192-4a5e-4954-b56e-b1a752783f91"  # Action ID for Generate Retro Coloring Book Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "a picture of TOK a very large and simple evil wizard with no nose. Coloring book vintage minimal lines easy to color",
    "loraScale": 0.6,
    "guidanceScale": 7.5,
    "applyWatermark": True,
    "negativePrompt": "complex, realistic, color, gradient",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "refinementStyle": "no_refiner",
    "highNoiseFraction": 0.8,
    "schedulingAlgorithm": "K_EULER",
    "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, you'll replace the placeholders with your specific API key and action ID. The input payload is structured according to the requirements defined in the action's schema.

Conclusion

Integrating the paappraiser/retro-coloring-book Cognitive Actions into your application allows for effortless image generation that can enhance user engagement and creativity. With customizable parameters and a straightforward API structure, you can easily create vintage-style images tailored to specific needs. Explore the possibilities and let your creativity flourish!