Generate Stunning Images with dazaleas/sd15-cog Cognitive Actions

In the world of image generation, the dazaleas/sd15-cog API offers developers a powerful toolset for creating high-quality images using the SD 1.5 model. With various customizable parameters, the Cognitive Actions in this spec provide an easy and efficient way to tailor your image creation process. From setting dimensions to controlling batch sizes and generation steps, these pre-built actions simplify the complexities of image synthesis, enabling developers to focus on creativity and application functionality.
Prerequisites
Before diving into the integration of these Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform to authenticate your requests.
- Familiarity with JSON and HTTP requests, as you'll be constructing payloads to interact with the API.
Authentication typically involves passing your API key in the request headers to verify your access rights.
Cognitive Actions Overview
Generate Image with SD 1.5 Cog
The Generate Image with SD 1.5 Cog action is designed to generate high-quality images based on user-defined parameters. It leverages the capabilities of the SD 1.5 model and provides extensive control over various aspects of the image creation process.
Category: Image Generation
Input
The input schema for this action consists of several fields that allow customization of the image generation process. Below is the breakdown of the required and optional fields:
- seed (integer): The initial value for random number generation. Defaults to -1 for a random seed.
- model (string): The identifier of the model to use for generating the output. Defaults to 'pastelmix.safetensors'.
- steps (integer): The number of steps for the generation process (1-100). Defaults to 35.
- width (integer): The pixel width of the generated image (1-2048). Defaults to 768.
- height (integer): The pixel height of the generated image (1-2048). Defaults to 768.
- prompt (string): Describes the desired content of the image. Defaults to "masterpiece, illustration, portrait of a beautiful young woman".
- batchSize (integer): The number of images to generate simultaneously (1-4). Defaults to 1.
- samplerName (string): The algorithm for sampling during generation. Defaults to "DPM++ 2M Karras".
- negativePrompt (string): Attributes to avoid in the generated image. Defaults to "low quality, bad quality, worst quality".
- denoisingStrength (number): Intensity of the denoising filter (0-1). Defaults to 0.35.
- configurationScale (number): Emphasis on the prompt during generation (1-20). Defaults to 7.
- highResolutionScale (integer): Factor for high-resolution output (1-4). Defaults to 2.
- enableHighResolution (boolean): Toggle for high-resolution generation. Defaults to false.
- highResolutionUpscaler (string): Algorithm for upscaling images. Defaults to "R-ESRGAN 4x+ Anime6B".
- variationalAutoencoder (string): Model used in generation. Defaults to "None".
- highResolutionSecondPassSteps (integer): Steps in the second pass of high-resolution generation (0-30). Defaults to 18.
Example Input:
{
"seed": -1,
"model": "xxmix.safetensors",
"steps": 35,
"width": 768,
"height": 768,
"prompt": "self-portrait oil painting of a beautiful young woman wearing an intricate dress, 8k, uhd, photorealistic, godrays",
"batchSize": 1,
"samplerName": "DPM++ SDE Karras",
"negativePrompt": "low quality, bad quality, worst quality, background art, mirror, reflection",
"denoisingStrength": 0.35,
"configurationScale": 7,
"highResolutionScale": 2,
"enableHighResolution": false,
"highResolutionUpscaler": "4x_fatal_Anime_500000_G",
"variationalAutoencoder": "consistency.pt",
"highResolutionSecondPassSteps": 18
}
Output
The output of this action typically returns a URL pointing to the generated image.
Example Output:
[
"https://assets.cognitiveactions.com/invocations/aa72df06-8f72-4571-bb94-f95b8f73e8f1/fa95119d-a47b-4dd6-8315-99dee9f2c270.png"
]
Conceptual Usage Example (Python)
Here’s how you might call the Cognitive Actions execution endpoint using Python to generate an image:
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 = "7955374a-91af-424e-848d-8bbf52f26b4d" # Action ID for Generate Image with SD 1.5 Cog
# Construct the input payload based on the action's requirements
payload = {
"seed": -1,
"model": "xxmix.safetensors",
"steps": 35,
"width": 768,
"height": 768,
"prompt": "self-portrait oil painting of a beautiful young woman wearing an intricate dress, 8k, uhd, photorealistic, godrays",
"batchSize": 1,
"samplerName": "DPM++ SDE Karras",
"negativePrompt": "low quality, bad quality, worst quality, background art, mirror, reflection",
"denoisingStrength": 0.35,
"configurationScale": 7,
"highResolutionScale": 2,
"enableHighResolution": False,
"highResolutionUpscaler": "4x_fatal_Anime_500000_G",
"variationalAutoencoder": "consistency.pt",
"highResolutionSecondPassSteps": 18
}
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 the placeholders for the API key and endpoint URL as needed. The payload dictionary is structured according to the input schema, allowing you to generate images as specified.
Conclusion
The dazaleas/sd15-cog Cognitive Actions empower developers to create stunning images tailored to their specifications with minimal effort. By leveraging these actions, you can enhance your applications with high-quality visuals that capture user attention. Whether you are building a creative tool or integrating image generation features into existing applications, these Cognitive Actions provide a robust foundation for your next project. Explore the possibilities and let your imagination run wild!