Create Stunning Retro Style Images with Cognitive Actions

21 Apr 2025
Create Stunning Retro Style Images with Cognitive Actions

Integrating image generation capabilities into your applications has never been easier, thanks to the Cognitive Actions provided in the sebastianbodza/flux_lora_retro_linedrawing_style_v1 spec. This set of actions allows developers to generate high-quality retro line drawing style images, utilizing a variety of customizable options. Whether you're looking to enhance visual content for a project or create unique art pieces, these pre-built actions offer a streamlined approach to image generation.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Familiarity with making HTTP requests and handling JSON data.
  • Basic understanding of image processing concepts.

Authentication typically involves passing your API key in the headers of your requests, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Retro Style Image

The Generate Retro Style Image action allows you to create images in a retro line drawing style. This action can operate in both image-to-image and inpainting modes, utilizing LoRA (Low-Rank Adaptation) and guidance scale for highly customizable results. You can specify various parameters to achieve the desired output format and quality.

Input

The action requires the following fields in its input schema:

  • prompt (string, required): A description of the image you want to generate. For instance, "Retro TOK illustration style of a portrait of Donald Trump".
  • mask (string, optional): URI for the image mask used in inpainting mode.
  • seed (integer, optional): An integer seed for reproducible image generation.
  • image (string, optional): URI for the input image used in image-to-image mode.
  • width (integer, optional): Width of the generated image (256 to 1440 pixels).
  • height (integer, optional): Height of the generated image (256 to 1440 pixels).
  • aspectRatio (string, default: "1:1"): Defines the aspect ratio for the generated image.
  • numOutputs (integer, default: 1): Number of images to generate (1 to 4).
  • outputFormat (string, default: "webp"): Desired output format (webp, jpg, png).
  • guidanceScale (number, default: 3): A scale for the guidance process (0 to 10).
  • outputQuality (integer, default: 80): Quality of the output images (0 to 100).
  • Additional parameters include extraLora, loraScale, goFast, and others, which allow for further customization.

Example Input:

{
  "width": 1440,
  "height": 1440,
  "prompt": "Retro TOK illustration style of a portrait of Donald Trump",
  "loraScale": 1,
  "numOutputs": 1,
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "extraLoraScale": 0.8,
  "modelSelection": "dev",
  "numInferenceSteps": 28
}

Output

The action typically returns a URL pointing to the generated image. For instance:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/0b4e0e4d-377b-4c9d-a180-924695ca7dbd/9e09a7e7-58d4-4434-9b24-d9b6d106d4e3.webp"
]

Conceptual Usage Example (Python)

Here's how you could call the Generate Retro Style 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 = "2e8090db-592f-4922-8367-34356716b441" # Action ID for Generate Retro Style Image

# Construct the input payload based on the action's requirements
payload = {
    "width": 1440,
    "height": 1440,
    "prompt": "Retro TOK illustration style of a portrait of Donald Trump",
    "loraScale": 1,
    "numOutputs": 1,
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "extraLoraScale": 0.8,
    "modelSelection": "dev",
    "numInferenceSteps": 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}
    )
    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 is structured according to the requirements of the action, ensuring that all necessary parameters are included.

Conclusion

The Cognitive Actions in the sebastianbodza/flux_lora_retro_linedrawing_style_v1 spec provide developers with powerful tools for generating retro style images. With customizable parameters, you can create unique images tailored to your needs. Start integrating these actions into your applications today to enhance your projects with stunning visual content!