Effortlessly Generate Stunning Images in Batches with AI

27 Apr 2025
Effortlessly Generate Stunning Images in Batches with AI

Creating visually appealing images from text descriptions has never been easier, thanks to the Ssd 1b Txt2img Batch service. This powerful tool allows developers to leverage advanced artificial intelligence capabilities to generate images from textual prompts efficiently. With its batch processing feature, you can input multiple prompts at once, making it ideal for projects that require high-volume image generation. Whether you're working on creative marketing materials, game assets, or visual content for social media, this service streamlines the process and enhances productivity.

Prerequisites

To get started with the Ssd 1b Txt2img Batch service, you will need an API key for Cognitive Actions and a basic understanding of making API calls.

Generate Images with Batch Prompts

The Generate Images with Batch Prompts action is designed to transform a list of text prompts into corresponding images using the Segmind Stable Diffusion Model (SSD-1B). This action enables users to specify various parameters, ensuring that the generated images align closely with their creative vision.

Input Requirements

The input for this action consists of several parameters:

  • seed (integer): A random seed to generate variations. Leave blank to randomize.
  • width (integer): The width of the output image in pixels (default is 768).
  • height (integer): The height of the output image in pixels (default is 768).
  • promptList (string): A newline-separated list of prompts for image generation.
  • guidanceIntensity (number): The strength of classifier-free guidance scaling, ranging from 1 to 50 (default is 7.5).
  • negativePromptList (string): A newline-separated list of elements to avoid in the generated images.
  • schedulingStrategy (string): The algorithm for the denoising process (default is 'K_EULER').
  • inferenceStepsCount (integer): The number of denoising steps to apply, between 1 and 500 (default is 25).

Example Input

{
  "seed": 36446545871,
  "width": 768,
  "height": 768,
  "promptList": "Wolf, paper, pointed ears, curled tail, sly expression with sharp folded eyes.\nLion, paper, pointed ears, curled tail, sly expression with sharp folded eyes.\nTiger, paper, pointed ears, curled tail, sly expression with sharp folded eyes.\nBear, paper, pointed ears, curled tail, sly expression with sharp folded eyes.",
  "guidanceIntensity": 7.5,
  "negativePromptList": "scary, cartoon, painting\nscary, cartoon, painting\nscary, cartoon, painting\nscary, cartoon, painting",
  "schedulingStrategy": "K_EULER",
  "inferenceStepsCount": 25
}

Expected Output

The action returns an array of URLs pointing to the generated images based on the provided prompts.

Example Output

[
  "https://assets.cognitiveactions.com/invocations/40bb8038-1570-4a32-b998-231b8e80c5b1/ed2779f1-0231-4438-a19b-07b3a9a36bc7.png",
  "https://assets.cognitiveactions.com/invocations/40bb8038-1570-4a32-b998-231b8e80c5b1/1e3381ec-e5b9-45b4-9593-9a3da8ea61e8.png",
  "https://assets.cognitiveactions.com/invocations/40bb8038-1570-4a32-b998-231b8e80c5b1/c1dadbef-1a57-43d4-90eb-e272ed686a13.png",
  "https://assets.cognitiveactions.com/invocations/40bb8038-1570-4a32-b998-231b8e80c5b1/de0b9072-f2e2-41c5-9b7b-a99116b79f04.png"
]

Use Cases for this Action

  • Creative Projects: Generate unique artwork or illustrations for books, games, and marketing materials.
  • Social Media Content: Quickly create visually engaging posts that resonate with audiences across platforms.
  • Prototyping and Concept Development: Visualize ideas and concepts rapidly, aiding in brainstorming and design processes.
  • Personalized Merchandise: Create custom images for products, enhancing customer engagement and satisfaction.

```python
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "95c3e75b-fd12-4c9d-ab56-259752c1ae01" # Action ID for: Generate Images with Batch Prompts

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "seed": 36446545871,
  "width": 768,
  "height": 768,
  "promptList": "Wolf, paper, pointed ears, curled tail, sly expression with sharp folded eyes.\nLion, paper, pointed ears, curled tail, sly expression with sharp folded eyes.\nTiger, paper, pointed ears, curled tail, sly expression with sharp folded eyes.\nBear, paper, pointed ears, curled tail, sly expression with sharp folded eyes.",
  "guidanceIntensity": 7.5,
  "negativePromptList": "scary, cartoon, painting\nscary, cartoon, painting\nscary, cartoon, painting\nscary, cartoon, painting",
  "schedulingStrategy": "K_EULER",
  "inferenceStepsCount": 25
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")


## Conclusion
The Ssd 1b Txt2img Batch service empowers developers to produce high-quality images from textual prompts in a streamlined manner. With features like batch processing and customizable parameters, this service is perfect for a variety of applications, from creative projects to marketing initiatives. Start integrating this powerful tool into your workflows today, and unlock the potential of AI-driven image generation.