Generate Stunning Images with MiaoMiao-Harem v1.5a Cognitive Actions

In the realm of image generation, the MiaoMiao-Harem v1.5a Cognitive Actions provide developers with powerful tools to create visually appealing images based on textual prompts. By leveraging these pre-built actions, you can easily customize image dimensions, batch sizes, and various parameters to enhance the quality of the generated images. This blog post will walk you through the integration process and showcase how to use the "Generate Image Using MiaoMiao-Harem-v1.5a" action effectively.
Prerequisites
Before you can start using the MiaoMiao-Harem v1.5a Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic understanding of making HTTP requests and handling JSON data.
To authenticate your requests, you will typically pass your API key in the headers of your HTTP calls. Ensure that you keep your API key secure and do not expose it in publicly accessible code.
Cognitive Actions Overview
Generate Image Using MiaoMiao-Harem-v1.5a
The Generate Image Using MiaoMiao-Harem-v1.5a action allows you to create images from textual prompts using the MiaoMiao-Harem v1.5a model. This action offers flexibility in terms of image dimensions and various other parameters to achieve high-quality results.
Input
The input schema for this action consists of several properties that guide the image generation:
- seed (integer): A specific seed for generation; set to -1 for a random seed.
Example:-1 - model (string): The model used for generation, defaulting to "MiaoMiao-Harem-v1.5a".
Example:"MiaoMiao-Harem-v1.5a" - width (integer): The width of the generated image in pixels, ranging from 1 to 4096. Default is 1024.
Example:1024 - height (integer): The height of the generated image in pixels, ranging from 1 to 4096. Default is 1024.
Example:1024 - prompt (string): A textual description guiding the image generation, following Compel weighting syntax.
Example:"street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V" - batchSize (integer): The number of images to generate (1-4), default is 1.
Example:1 - clipLayerSkip (integer): Number of CLIP layers to skip, with a minimum of 1.
Example:2 - schedulerType (string): The scheduling algorithm for image generation, default is "Euler a".
Example:"Euler a" - generationSteps (integer): Number of steps for generating the image (1-100), default is 30.
Example:30 - configurationScale (number): CFG scale for model focus on the prompt, default is 6.
Example:6 - prependInitialPrompt (boolean): Whether to prepend a predefined prompt; default is true.
Example:true - variationalAutoEncoder (string): The VAE to use for generation, default is "default".
Example:"default" - guidanceRescalingFactor (number): Rescale factor for CFG-generated noise, default is 0.5.
Example:1 - negativeGenerationPrompt (string): Features to avoid in the generation.
Example:"nsfw, naked" - progressiveAttentionGuidanceScale (number): Enhances result quality, default is 3.
Example:0
Here's an example of the complete input JSON payload:
{
"seed": -1,
"model": "MiaoMiao-Harem-v1.5a",
"width": 1024,
"height": 1024,
"prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
"batchSize": 1,
"clipLayerSkip": 2,
"schedulerType": "Euler a",
"generationSteps": 30,
"configurationScale": 6,
"prependInitialPrompt": true,
"variationalAutoEncoder": "default",
"guidanceRescalingFactor": 1,
"negativeGenerationPrompt": "nsfw, naked",
"progressiveAttentionGuidanceScale": 0
}
Output
Upon successful execution, the action returns an array of URLs pointing to the generated images. A typical output example is:
[
"https://assets.cognitiveactions.com/invocations/7f71d3c5-0349-4bad-a427-35aa2715d1ce/b42c7498-a222-4198-b3df-a55a7b5517cd.png"
]
This output contains the link(s) to the generated image(s), which you can then use as needed in your application.
Conceptual Usage Example (Python)
Here’s a conceptual Python code snippet demonstrating how to call the Cognitive Actions execution endpoint for this action:
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 = "28465d3a-b86b-4a48-bea3-0906c03a3ee" # Action ID for Generate Image Using MiaoMiao-Harem-v1.5a
# Construct the input payload based on the action's requirements
payload = {
"seed": -1,
"model": "MiaoMiao-Harem-v1.5a",
"width": 1024,
"height": 1024,
"prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
"batchSize": 1,
"clipLayerSkip": 2,
"schedulerType": "Euler a",
"generationSteps": 30,
"configurationScale": 6,
"prependInitialPrompt": True,
"variationalAutoEncoder": "default",
"guidanceRescalingFactor": 1,
"negativeGenerationPrompt": "nsfw, naked",
"progressiveAttentionGuidanceScale": 0
}
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 code, replace "YOUR_COGNITIVE_ACTIONS_API_KEY" with your actual API key. The payload is structured according to the action's input schema, and the request is sent to a hypothetical execution endpoint.
Conclusion
The MiaoMiao-Harem v1.5a Cognitive Actions provide a robust solution for generating images from text prompts with customizable parameters. By following the guidelines outlined in this post, you can easily integrate this action into your applications and start creating stunning visuals tailored to your needs. Explore further use cases and consider experimenting with different prompts and parameters for diverse outputs!