Generate Stunning Images with the titowmn/tito Cognitive Actions

22 Apr 2025
Generate Stunning Images with the titowmn/tito Cognitive Actions

In the realm of AI-driven creativity, the titowmn/tito Cognitive Actions offer developers powerful tools for generating high-quality images. With the ability to create inpainted images using advanced models like 'dev' and 'schnell', these actions provide a simple yet effective way to enhance applications that require sophisticated image manipulation or generation. Let’s dive into how you can harness these actions in your own projects.

Prerequisites

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

  • An API key for the Cognitive Actions platform, which will be used for authentication.
  • Basic knowledge of making HTTP requests and handling JSON payloads.

Authentication typically involves including your API key in the request headers, allowing secure access to the actions provided by the platform.

Cognitive Actions Overview

Generate Inpainted Image

The Generate Inpainted Image action enables you to produce high-quality images through image-to-image transformations and inpainting techniques. This action supports various configurations, including guidance scale, output quality, and dimension adjustments.

Input

The input schema for the Generate Inpainted Image action requires the following fields:

  • prompt (required): A textual description guiding the image generation process.
  • aspectRatio (optional): Defines the image aspect ratio (e.g., "1:1", "16:9").
  • outputFormat (optional): The desired output file format (e.g., "webp", "jpg").
  • guidanceScale (optional): Influences the diffusion process (default: 3).
  • mainLoraScale (optional): Adjusts the strength of the main LoRA application.
  • outputQuality (optional): Sets quality for saving images (default: 80).
  • inferenceModel (optional): Selects the model for inference ("dev" or "schnell").
  • promptStrength (optional): Determines the extent of prompt influence.
  • numberOfOutputs (optional): Specifies how many images to generate.

Here’s an example of the expected input JSON payload:

{
  "prompt": "In TITO style. Handsome semi-wavy hair thin face surfer in a sunset beach, with his surfboard",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "mainLoraScale": 1,
  "outputQuality": 90,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Output

The output of this action typically returns the generated image in the specified format. Here’s an example of what you might receive:

[
  "https://assets.cognitiveactions.com/invocations/b3f7c3e3-28b2-4527-ac59-7118f95bee19/da594f7f-2b96-44b2-9aef-db9242a9da71.webp"
]

This URL links directly to the generated image, which can be displayed or further processed in your application.

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to invoke the Generate Inpainted 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 = "3485e7d4-c172-415e-a143-24a57611c2f6"  # Action ID for Generate Inpainted Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "In TITO style. Handsome semi-wavy hair thin face surfer in a sunset beach, with his surfboard",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "mainLoraScale": 1,
    "outputQuality": 90,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "additionalLoraScale": 1,
    "numberOfInferenceSteps": 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}  # 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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is constructed according to the action's requirements, and the response is handled to display the result or any errors encountered.

Conclusion

The titowmn/tito Cognitive Actions provide a robust, straightforward way to generate stunning images tailored to your specifications. With just a few lines of code, you can create visually appealing content for various applications, from creative projects to innovative solutions in image processing. Explore these actions further and unlock new possibilities for your applications!