Colorize Historical Images with Cognitive Actions from Neurealhistory

24 Apr 2025
Colorize Historical Images with Cognitive Actions from Neurealhistory

In the digital age, the ability to transform historical images into vibrant, colorized versions is a fascinating application of AI technology. The Neurealhistory Cognitive Actions provide developers with pre-built functionalities that leverage advanced models to generate stunning, colorized images reminiscent of the early inter-War era. This guide will walk you through the capabilities offered by the Generate Colorized Historical Images action, its input requirements, expected outputs, and how to integrate it into your applications.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON data.

For authentication, you typically need to include your API key in the headers of your requests, allowing you to securely access the actions.

Cognitive Actions Overview

Generate Colorized Historical Images

Description: This action generates colorized historical-style images using the SDXL model, which has been fine-tuned on manually colorized historical photos. It is ideal for creating images that capture the essence of parlor portrait styles from the early inter-War era.

Category: Image Generation

Input

The action requires a structured input payload, which can include the following fields:

FieldTypeDescription
maskstringURI for the input mask used in inpaint mode. Black areas remain intact, white areas are modified.
seedintegerSeed for random number generation. Leave blank for random seeding.
imagestringURI for the input image used in img2img or inpaint mode.
widthintegerWidth of the output image in pixels (default: 1024).
heightintegerHeight of the output image in pixels (default: 1024).
promptstringText prompt describing the desired content/styles of the output image.
refinestringSelect the refinement style for enhancing image output (options: no_refiner, expert_ensemble_refiner, base_image_refiner).
loraScalenumberLoRA additive scale, applicable to trained models (default: 0.6).
schedulerstringAlgorithm managing the image generation process (default: K_EULER).
refineStepsintegerNumber of refinement steps when using base_image_refiner.
addWatermarkbooleanApply a watermark to identify generated images (default: true).
guidanceScalenumberFactor for classifier-free guidance in generating images (default: 7.5).
negativePromptstringText prompt specifying undesirable elements to exclude from the output image.
promptStrengthnumberStrength of the prompt's influence in img2img/inpaint modes (default: 0.8).
numberOfOutputsintegerNumber of images to generate (default: 1, range: 1 to 4).
highNoiseFractionnumberControls the fraction of noise applied for expert_ensemble_refiner (range: 0 to 1).
numberOfInferenceStepsintegerTotal number of denoising steps during image generation (default: 50, range: 1 to 500).

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "HST style Voltaire, analog color photo",
  "refine": "no_refiner",
  "loraScale": 0.73,
  "scheduler": "DPMSolverMultistep",
  "addWatermark": false,
  "guidanceScale": 8.67,
  "negativePrompt": "cross-eyed, wrong eyes, wrong hands, deformed",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "highNoiseFraction": 0.8,
  "numberOfInferenceSteps": 50
}

Output

Upon successful execution, the action returns a URL to the generated image. Here's what a typical response might look like:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/17f84106-114a-4646-aae0-88e0c875c783/bfd4deb0-a4df-4349-acf2-19340957da6b.png"
]

Conceptual Usage Example (Python)

Here is a conceptual Python code snippet demonstrating how to invoke the Generate Colorized Historical Images 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 = "ffb4e2e0-d5fd-4a2f-b957-89c89d7b427e"  # Action ID for Generate Colorized Historical Images

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "HST style Voltaire, analog color photo",
    "refine": "no_refiner",
    "loraScale": 0.73,
    "scheduler": "DPMSolverMultistep",
    "addWatermark": False,
    "guidanceScale": 8.67,
    "negativePrompt": "cross-eyed, wrong eyes, wrong hands, deformed",
    "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 corresponds to the Generate Colorized Historical Images action, and the payload is structured according to the input schema we discussed. The endpoint URL and request structure are illustrative, so ensure they align with your actual implementation.

Conclusion

The Neurealhistory Cognitive Actions empower developers to create compelling, colorized historical images with ease. By utilizing the Generate Colorized Historical Images action, you can transform your applications with vibrant visuals that bring history to life. Explore the potential of image generation and consider how these capabilities can enhance your projects, whether for artistic endeavors, educational tools, or content creation. Happy coding!