Create Stunning Supermarionation Images with the cjwbw/supermarionation Cognitive Actions

25 Apr 2025
Create Stunning Supermarionation Images with the cjwbw/supermarionation Cognitive Actions

The cjwbw/supermarionation API provides developers with the unique capability to generate images in the distinctive Supermarionation style, inspired by the classic Gerry Anderson's Thunderbirds TV series. Utilizing a fine-tuned Stable Diffusion model, these Cognitive Actions allow you to create imaginative and visually striking images based on user-defined prompts and input images. This article will guide you through the process of integrating this action into your applications, showcasing its input requirements, output results, and a practical Python example.

Prerequisites

Before you start using the Cognitive Actions, you will need:

  • API Key: A valid API key for the Cognitive Actions platform to authenticate your requests.
  • Setup: Ensure you have access to make HTTP requests from your programming environment.

Typically, authentication is handled by including your API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Supermarionation Style Image

The Generate Supermarionation Style Image action allows you to create images that capture the essence of the Supermarionation style. This action is particularly useful for artists, developers, and creators looking to integrate unique visual elements into their projects.

Input

This action requires a structured input schema, detailed below:

{
  "image": "https://example.com/image.jpg",
  "width": 512,
  "height": 512,
  "prompt": "Brad Pitt in supermarionation style",
  "scheduler": "K_EULER",
  "guidanceScale": 7,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 50
}
  • image (string, required): A URI pointing to the input image for the img2img generation process.
  • width (integer, optional): Width of the output image (default is 512). Options range from 128 to 1024.
  • height (integer, optional): Height of the output image (default is 512). Same range as width.
  • prompt (string, optional): Text prompt guiding the image generation (default is empty).
  • scheduler (string, optional): Scheduler for the generation process (default is "K_EULER").
  • guidanceScale (number, optional): Scale for classifier-free guidance (default is 7, range 1-20).
  • negativePrompt (string, optional): Prompt(s) to avoid during generation, applicable only when using guidance.
  • numberOfOutputs (integer, optional): Number of images to generate (default is 1, options are 1 or 4).
  • numberOfInferenceSteps (integer, optional): Number of denoising steps (default is 50, range 1-500).

Example Input

Here’s an example input that you can use for the action:

{
  "image": "https://replicate.delivery/pbxt/IPYBr61UJghgxqHNIP8Cw1Ky06v2gVQBtMrQoSOqyR0fCuWT/bradd.jpeg",
  "width": 512,
  "height": 512,
  "prompt": "Brad Pitt in supermarionation style",
  "scheduler": "K_EULER",
  "guidanceScale": 7,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 50
}

Output

Upon successful execution, the action returns an array of URLs pointing to the generated images. Here’s an example output:

[
  "https://assets.cognitiveactions.com/invocations/ce22d3b7-5015-455e-ab70-a9b1e5e55e6c/863d4383-dcb1-402e-8f71-0f07424a266e.png"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to invoke the Generate Supermarionation Style Image 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 = "ee9ab4c7-20ab-4ccd-b9d0-216dba929fbb"  # Action ID for Generate Supermarionation Style Image

# Construct the input payload based on the action's requirements
payload = {
    "image": "https://replicate.delivery/pbxt/IPYBr61UJghgxqHNIP8Cw1Ky06v2gVQBtMrQoSOqyR0fCuWT/bradd.jpeg",
    "width": 512,
    "height": 512,
    "prompt": "Brad Pitt in supermarionation style",
    "scheduler": "K_EULER",
    "guidanceScale": 7,
    "numberOfOutputs": 1,
    "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 example, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is populated with the necessary inputs based on the action's schema. The response is handled gracefully, providing insight into any errors that may occur.

Conclusion

The cjwbw/supermarionation Cognitive Actions empower developers to create unique, visually captivating images that stand out in any application. By leveraging the flexibility and ease of use of these actions, you can integrate creative image generation into your projects seamlessly. Explore the possibilities and consider using this action for your next app or creative project!