Create Stunning Images with lucataco/ssd-1b Cognitive Actions

23 Apr 2025
Create Stunning Images with lucataco/ssd-1b Cognitive Actions

In the world of artificial intelligence, transforming text into visually captivating images has become a remarkable feat. The lucataco/ssd-1b specification leverages the powerful Segmind Stable Diffusion Model (SSD-1B) for high-quality text-to-image generation. This model, designed for speed and efficiency, allows developers to create unique images by simply providing descriptive prompts. In this article, we will explore how to integrate and utilize the Cognitive Action for image generation provided in this specification.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of making HTTP requests and handling JSON in your application.

To authenticate your requests, you will typically pass your API key in the headers of your HTTP requests. This ensures that your application can securely interact with the Cognitive Actions API.

Cognitive Actions Overview

Generate Images with Segmind Stable Diffusion

Description:
This action utilizes the Segmind Stable Diffusion Model for generating high-quality images from text prompts. The model is optimized for speed, providing a 60% performance boost while maintaining exceptional image quality through diverse training datasets.

Category: Image Generation

Input

The input schema for this action is structured as follows:

  • prompt: (string) Required. Text that guides the content and style of the output image.
  • width: (integer) Optional. Width of the output image in pixels (default: 768).
  • height: (integer) Optional. Height of the output image in pixels (default: 768).
  • seed: (integer) Optional. Seed for random number generation (default: random).
  • numOutputs: (integer) Optional. Number of images to generate (default: 1, max: 4).
  • guidanceScale: (number) Optional. Classifier-free guidance scale (default: 7.5, range: 1-50).
  • applyWatermark: (boolean) Optional. Indicates if a watermark should be applied (default: true).
  • imageScheduler: (string) Optional. The algorithm used for image generation (default: "K_EULER").
  • negativePrompt: (string) Optional. Specifies undesirable elements in the image.
  • promptStrength: (number) Optional. Influences the prompt's role in img2img or inpainting tasks (default: 0.8, range: 0-1).
  • numInferenceSteps: (integer) Optional. Number of denoising steps during generation (default: 25).
  • batchedPrompt: (boolean) Optional. If true, the prompt is split by newlines for multiple images (default: false).
  • loraScale: (number) Optional. Scaling factor for LoRA (default: 0.6, range: 0-1).
  • mask: (string) Optional. URI of the input mask for inpainting.
  • image: (string) Optional. URI of the input image for img2img or inpainting.
  • modelWeights: (string) Optional. LoRA model weights to use for generation.
  • disableSafetyChecker: (boolean) Optional. Deactivates the safety checker for generated images (default: false).

Example Input:

{
  "seed": 36446545872,
  "width": 768,
  "height": 768,
  "prompt": "with smoke, half ice and half fire and ultra realistic in detail.wolf, typography, dark fantasy, wildlife photography, vibrant, cinematic and on a black background",
  "loraScale": 0.6,
  "numOutputs": 1,
  "batchedPrompt": false,
  "guidanceScale": 9,
  "applyWatermark": true,
  "imageScheduler": "K_EULER",
  "negativePrompt": "scary, cartoon, painting",
  "promptStrength": 0.8,
  "numInferenceSteps": 25
}

Output

The action produces an array of URLs pointing to the generated images. For instance, a successful output might look like this:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/3be416bf-0367-4106-8902-9b84d309c88b/1216faa2-7209-40c3-929f-85e3b5bfdf91.png"
]

Conceptual Usage Example (Python)

Here’s how you might implement this action in 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 = "2885333f-4280-4df8-8b89-52ba5e27aac9" # Action ID for Generate Images with Segmind Stable Diffusion

# Construct the input payload based on the action's requirements
payload = {
    "seed": 36446545872,
    "width": 768,
    "height": 768,
    "prompt": "with smoke, half ice and half fire and ultra realistic in detail.wolf, typography, dark fantasy, wildlife photography, vibrant, cinematic and on a black background",
    "loraScale": 0.6,
    "numOutputs": 1,
    "batchedPrompt": False,
    "guidanceScale": 9,
    "applyWatermark": True,
    "imageScheduler": "K_EULER",
    "negativePrompt": "scary, cartoon, painting",
    "promptStrength": 0.8,
    "numInferenceSteps": 25
}

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, you will need to replace the placeholder for your API key and the endpoint URL. The payload variable is structured to match the input requirements of the action, allowing you to generate stunning images seamlessly.

Conclusion

The lucataco/ssd-1b Cognitive Actions empower developers to harness the capabilities of the Segmind Stable Diffusion Model for creative image generation. By utilizing the provided action, you can easily create high-quality images from textual descriptions. Explore various prompts and settings to discover the full potential of this powerful tool and enhance your applications with captivating visuals!