Generate Custom Images with Cognitive Actions from dhanushreddy291/ssd-1b-lcm

22 Apr 2025
Generate Custom Images with Cognitive Actions from dhanushreddy291/ssd-1b-lcm

In the realm of image generation, the dhanushreddy291/ssd-1b-lcm Cognitive Actions bring a powerful toolset for developers looking to create customized images based on textual descriptions. This API enables you to generate images that are not only aligned with prompts but also highly customizable in terms of quality and content. By leveraging these pre-built actions, developers can efficiently incorporate image generation capabilities into their applications without the need for extensive machine learning expertise.

Prerequisites

To get started with the Cognitive Actions, you'll need an API key from the Cognitive Actions platform. This key will be used for authentication when making API requests. Authentication typically involves including your API key in the headers of your requests.

Cognitive Actions Overview

Generate Custom Images

The Generate Custom Images action allows developers to create images tailored to specific textual descriptions. This action provides various parameters to control the output, including the alignment with the prompt and the inclusion of specific elements.

  • Category: Image Generation

Input

The input schema for this action is defined as follows:

{
  "seed": 123456,                 // Optional integer for reproducible results
  "prompt": "a close-up picture of an old man standing in the forest", // Required string for image description
  "guidanceScale": 8,            // Optional number to influence prompt adherence (0-10)
  "negativePrompt": "",           // Optional string for elements to avoid in the image
  "numberOfOutputs": 2,          // Optional integer for number of images to generate (1-4)
  "numberOfInferenceSteps": 4     // Optional integer for processing iterations (1-10)
}

Example Input:

{
  "prompt": "a close-up picture of an old man standing in the forest",
  "guidanceScale": 8,
  "negativePrompt": "",
  "numberOfOutputs": 2,
  "numberOfInferenceSteps": 4
}

Output

The action typically returns an array of URLs pointing to the generated images.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/373aae1a-4ad8-4d0e-a1fb-4619c76e2f44/e0691846-63c0-4820-bef9-df636478e90d.png",
  "https://assets.cognitiveactions.com/invocations/373aae1a-4ad8-4d0e-a1fb-4619c76e2f44/4451c17c-1485-4da8-bb5a-1b1573a4f7e3.png"
]

Conceptual Usage Example (Python)

Here is a conceptual example of how you might call this 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 = "3a42e5f7-b812-4545-82e2-fb7ceb672d5c"  # Action ID for Generate Custom Images

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "a close-up picture of an old man standing in the forest",
    "guidanceScale": 8,
    "negativePrompt": "",
    "numberOfOutputs": 2,
    "numberOfInferenceSteps": 4
}

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 Python code snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the input requirements of the Generate Custom Images action. The endpoint URL and request structure are illustrative and designed to show how you could interact with the Cognitive Actions API.

Conclusion

The Generate Custom Images action from the dhanushreddy291/ssd-1b-lcm Cognitive Actions empowers developers to create tailored images based on textual descriptions seamlessly. By utilizing parameters like guidance scale and inference steps, you can enhance the quality and relevance of the generated images. As you integrate these capabilities into your applications, consider exploring additional use cases and experimenting with different prompts to fully leverage the potential of image generation. Happy coding!