Generate High-Resolution Images with the jyoung105/lcm Cognitive Actions

22 Apr 2025
Generate High-Resolution Images with the jyoung105/lcm Cognitive Actions

In the world of artificial intelligence and content creation, generating high-quality images has become increasingly important. The jyoung105/lcm Cognitive Actions provide developers with a powerful API for synthesizing high-resolution images using Latent Consistency Models. These actions facilitate the production of images with a balance of fidelity and diversity, enabling a range of creative applications. In this post, we'll explore how to leverage these Cognitive Actions to enhance your applications.

Prerequisites

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

  • An API key for accessing the Cognitive Actions platform.
  • Basic knowledge of JSON and API calls.

To authenticate your requests, you will typically pass your API key in the request headers. This is essential to ensure secure access to the Cognitive Actions.

Cognitive Actions Overview

Generate High-Resolution Images

The Generate High-Resolution Images action allows you to synthesize images based on a text prompt. By utilizing Latent Consistency Models, this action enables you to create visually stunning images that maintain high fidelity while allowing for creative diversity.

Input

The input for this action is structured as follows:

{
  "eta": 0,
  "seed": null,
  "steps": 4,
  "width": 1024,
  "height": 1024,
  "prompt": "A man with hoodie on, illustration",
  "clipSkip": 0,
  "guidanceScale": 0,
  "negativePrompt": null,
  "numberOfImages": 1
}

Parameters:

  • eta (number, default: 0): Controls randomness (0 to 1).
  • seed (integer): Sets a random seed for reproducibility; leave blank to randomize.
  • steps (integer, default: 4): Number of denoising steps (1 to 50).
  • width (integer, default: 1024): Width of the output image in pixels (1 to 2048).
  • height (integer, default: 1024): Height of the output image in pixels (1 to 2048).
  • prompt (string): Text description of the desired output.
  • clipSkip (integer, default: 0): Layers to skip in CLIP during inference.
  • guidanceScale (number, default: 0): Classifier-free guidance scale (0 to 20).
  • negativePrompt (string): Text for undesired elements in the output.
  • numberOfImages (integer, default: 1): Number of images to generate (1 to 4).

Example Input

Here’s an example of a JSON payload you would send to generate an image:

{
  "eta": 0,
  "steps": 4,
  "width": 1024,
  "height": 1024,
  "prompt": "A man with hoodie on, illustration",
  "clipSkip": 0,
  "guidanceScale": 0,
  "numberOfImages": 1
}

Output

Upon successful execution of the action, you will typically receive a response containing the URL(s) of the generated image(s), for example:

[
  "https://assets.cognitiveactions.com/invocations/c52694b3-04a5-41f7-b59d-1909db3fe75e/305f9ef1-5733-469c-acc9-614b083d1fcf.png"
]

Conceptual Usage Example (Python)

Here’s how you might call the Generate High-Resolution Images 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 = "ca3fd0fa-67c7-4ad0-b78d-26ef7d7c0506"  # Action ID for Generate High-Resolution Images

# Construct the input payload based on the action's requirements
payload = {
    "eta": 0,
    "steps": 4,
    "width": 1024,
    "height": 1024,
    "prompt": "A man with hoodie on, illustration",
    "clipSkip": 0,
    "guidanceScale": 0,
    "numberOfImages": 1
}

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 contains the input parameters required by the action. The requests.post call sends the request, and the response is handled accordingly.

Conclusion

The jyoung105/lcm Cognitive Actions provide a robust solution for developers seeking to create high-resolution images through a simple API. By integrating these actions into your applications, you can enhance user experience and broaden creative possibilities. As you explore further, think about potential use cases ranging from art generation to content creation and beyond. Happy coding!