Generating Stunning Images with the dunaevai135/tst2_d Cognitive Actions

24 Apr 2025
Generating Stunning Images with the dunaevai135/tst2_d Cognitive Actions

In the world of artificial intelligence, image generation has emerged as a powerful tool for artists, developers, and content creators. The dunaevai135/tst2_d spec provides a robust set of Cognitive Actions, enabling developers to generate images with inpainting capabilities and extensive customization options. These pre-built actions facilitate quick integration into applications, allowing you to harness advanced image processing without needing to build complex algorithms from scratch.

Prerequisites

Before diving into the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making API requests in your preferred programming language.

Authentication typically involves passing your API key in the request headers to access the available actions.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action allows developers to create images based on text prompts while supporting advanced options like inpainting, model configuration, and resolution adjustments. This action is particularly useful for generating unique visuals quickly.

Input

The input schema for this action requires specific fields, notably the prompt. Below is a detailed breakdown:

  • Required Field:
    • prompt: A string representing the text prompt for generating the image (e.g., "a photo of DUN, man").
  • Optional Fields:
    • mask: URI of the image mask for inpainting mode.
    • seed: Integer for reproducible image generation.
    • image: URI of the input image for inpainting.
    • model: Specifies the model to run inference with (options: dev, schnell).
    • width and height: Dimensions of the generated image in pixels (only for custom aspect ratios).
    • aspectRatio: Defines the aspect ratio (default: 1:1).
    • outputCount: Number of images to generate (default: 1, max: 4).
    • outputFormat: Format of the output images (options: webp, jpg, png).
    • Additional tuning parameters like guidanceScale, loraIntensity, and outputQuality.

Example Input:

{
  "model": "dev",
  "prompt": "a photo of DUN, man",
  "aspectRatio": "1:1",
  "outputCount": 2,
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "loraIntensity": 1,
  "outputQuality": 80,
  "denoisingStepCount": 28,
  "additionalLoraIntensity": 0.8
}

Output

The action typically returns an array of URIs pointing to the generated images. Each URI links to a distinct image created based on the provided prompt and parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/c7e1e23b-fc92-47a8-9163-db6f04f09dbd/c16f7ef3-be6f-4cd1-9b8d-c66543a85ceb.webp",
  "https://assets.cognitiveactions.com/invocations/c7e1e23b-fc92-47a8-9163-db6f04f09dbd/3f43769c-96a7-4c00-aa0d-ea00277f7953.webp"
]

Conceptual Usage Example (Python)

Here’s how a developer might invoke the Generate Image with Inpainting action using a Python code snippet:

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 = "a8fb4af0-3ba0-4072-b69b-6c583e90d343" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "a photo of DUN, man",
    "aspectRatio": "1:1",
    "outputCount": 2,
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "loraIntensity": 1,
    "outputQuality": 80,
    "denoisingStepCount": 28,
    "additionalLoraIntensity": 0.8
}

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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the required input fields, and the request sends this data to the hypothetical execution endpoint.

Conclusion

The dunaevai135/tst2_d Cognitive Actions empower developers to create unique images efficiently using inpainting and customizable parameters. By integrating these actions into your application, you can automate and enhance creative workflows, making it easier to produce high-quality visuals tailored to your needs. Explore the potential of these actions to elevate your projects!