Crafting Custom Images with MiaoMiao-Harem-v1.5b Cognitive Actions

The MiaoMiao-Harem-v1.5b Cognitive Actions offer developers an exciting opportunity to integrate advanced image generation capabilities into their applications. By leveraging the power of Variational Autoencoders and ADetailer models, these actions enable seamless customization of images, allowing users to control various aspects such as dimensions, styles, and details. Whether you are building a creative application or enhancing user-generated content, these pre-built actions can significantly reduce development time while providing powerful tools for image manipulation.
Prerequisites
Before diving into the integration of Cognitive Actions, ensure you have the following:
- An API key for the Cognitive Actions platform.
- Basic setup of your development environment capable of making HTTP requests.
- Familiarity with JSON format for constructing request payloads.
Authentication typically involves including your API key in the request headers, allowing you to securely access the Cognitive Actions service.
Cognitive Actions Overview
Generate Custom AI Image
The Generate Custom AI Image action is designed to create detailed and customizable images using the MiaoMiao-Harem-v1.5b model. It allows developers to fine-tune image generation with a variety of parameters, including prompts, schedulers, and CFG scale.
Input
The action requires the following input fields:
- vae: Specifies the Variational Autoencoder (VAE) to use. Options include
"default","Liquid111","NeptuniaXL-VAE-ContrastSaturation", and"MiaoMiao-Harem-v1.5b". - seed: An integer seed for image generation, where
-1means a random seed. - model: The model used for image generation, which is
"MiaoMiao-Harem-v1.5b". - steps: An integer defining the number of steps in the image generation process (1 - 100).
- width: The image width in pixels (1 - 4096).
- height: The image height in pixels (1 - 4096).
- prompt: A string providing the main guidance for the image's content and style.
- upscale: The upscale factor for the image, with options including
"Original","x2","x4", and"x8". - cfgScale: A number dictating adherence to the prompt (1 - 50).
- clipSkip: An integer indicating how many CLIP layers to skip (minimum 1).
- pagScale: A number that enhances CFG (0 - 50).
- batchSize: The number of images to generate simultaneously (1 - 4).
- scheduler: A string that specifies the scheduler for processing the image generation.
- adetailerFace: A boolean to enable face detection enhancements.
- adetailerHand: A boolean for improving hand depiction.
- negativePrompt: A string defining undesired elements in the image.
- adetailerPerson: A boolean for person detection enhancement.
- guidanceRescale: A number for rescaling generated noise (0 - 5).
- prependPreprompt: A boolean to insert predefined attributes in prompts.
- Additional fields are available for fine-tuning face, hand, and person details with ADetailer.
A practical example of the input JSON payload looks like this:
{
"vae": "NeptuniaXL-VAE-ContrastSaturation",
"seed": -1,
"model": "MiaoMiao-Harem-v1.5b",
"steps": 30,
"width": 1024,
"height": 1024,
"prompt": "park, spring, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V, upper body",
"upscale": "x4",
"cfgScale": 6,
"clipSkip": 2,
"pagScale": 0,
"scheduler": "Euler a",
"adetailerFace": false,
"adetailerHand": false,
"negativePrompt": "nsfw, naked",
"adetailerPerson": false,
"guidanceRescale": 1,
"prependPreprompt": true
}
Output
Upon successful execution, the action typically returns a URL to the generated image. For example:
[
"https://assets.cognitiveactions.com/invocations/51179fad-aed6-4ec5-a89c-136ddfbe9bac/62020308-fed8-42e7-b5c8-49c8f1c90511.png"
]
Conceptual Usage Example (Python)
Here’s a conceptual Python snippet demonstrating how to call the Generate Custom AI Image 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 = "f12af32f-ed2d-4fa6-8691-3a52e24ea74f" # Action ID for Generate Custom AI Image
# Construct the input payload based on the action's requirements
payload = {
"vae": "NeptuniaXL-VAE-ContrastSaturation",
"seed": -1,
"model": "MiaoMiao-Harem-v1.5b",
"steps": 30,
"width": 1024,
"height": 1024,
"prompt": "park, spring, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V, upper body",
"upscale": "x4",
"cfgScale": 6,
"clipSkip": 2,
"pagScale": 0,
"scheduler": "Euler a",
"adetailerFace": false,
"adetailerHand": false,
"negativePrompt": "nsfw, naked",
"adetailerPerson": false,
"guidanceRescale": 1,
"prependPreprompt": true
}
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, the action ID and input payload are correctly structured to invoke the Generate Custom AI Image action. The endpoint URL and request structure are illustrative and meant to guide you in the integration process.
Conclusion
The MiaoMiao-Harem-v1.5b Cognitive Actions provide a robust framework for generating custom images tailored to your application's needs. With options for fine-tuning various parameters, developers can create unique and engaging visuals with relative ease. Consider exploring additional use cases or optimizing the parameters to maximize the potential of your image generation capabilities. Start integrating today and unleash the creativity of your applications!