Unleashing Creativity: Generating Custom Images with MiaoMiao-Harem v1.5b Cognitive Actions

23 Apr 2025
Unleashing Creativity: Generating Custom Images with MiaoMiao-Harem v1.5b Cognitive Actions

In today's digital landscape, image generation has become an exciting frontier powered by AI. The MiaoMiao-Harem v1.5b model provides developers with an opportunity to create stunning custom images based on user-defined prompts. This powerful set of Cognitive Actions enables you to harness AI's creativity, offering control over various parameters for enhanced customization. In this blog post, we'll explore the Generate Custom Images action and guide you on integrating it into your applications.

Prerequisites

Before diving into the integration, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of working with REST APIs.
  • Familiarity with JSON for constructing requests and handling responses.

For authentication, you will typically pass your API key in the headers of your requests. This allows you to securely access the Cognitive Actions API.

Cognitive Actions Overview

Generate Custom Images

The Generate Custom Images action utilizes the MiaoMiao-Harem-v1.5b model to create images based on a user-defined prompt. This action is categorized under image-generation and offers extensive customization options.

Input

The input for this action consists of several parameters, each allowing fine-tuning of the image generation process. Here’s a breakdown of the required and optional fields based on the input schema:

  • seed (integer): The seed value for generating output. Set to -1 for a random seed.
  • model (string): The model to be utilized, which must be "MiaoMiao-Harem-v1.5b".
  • steps (integer): Number of steps for generation (1-100). Default is 30.
  • width (integer): Image width in pixels (1-4096). Default is 1024.
  • height (integer): Image height in pixels (1-4096). Default is 1024.
  • prompt (string): The input prompt for image generation, utilizing Compel weighting syntax.
  • cfgScale (number): Controls prompt adherence (1-50). Default is 5.
  • clipSkip (integer): Number of CLIP layers to skip (minimum 1).
  • pagScale (number): Adjusts the PAG scale (0-50). Default is 3.
  • batchSize (integer): Number of images to generate per request (1-4). Default is 1.
  • scheduler (string): Selects the scheduler algorithm for image generation.
  • negativePrompt (string): Elements to exclude in the generated image.
  • guidanceRescale (number): Rescales CFG-generated noise (0-5). Default is 0.5.
  • prependPreprompt (boolean): Indicates whether to prepend a default high-quality preprompt. Default is true.
  • variationalAutoencoder (string): Designates the VAE for use ("default" or "MiaoMiao-Harem-v1.5b").

Example Input:

{
  "seed": -1,
  "model": "MiaoMiao-Harem-v1.5b",
  "steps": 30,
  "width": 1024,
  "height": 1024,
  "prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
  "cfgScale": 6,
  "clipSkip": 2,
  "pagScale": 0,
  "batchSize": 1,
  "scheduler": "Euler a",
  "negativePrompt": "nsfw, naked",
  "guidanceRescale": 1,
  "prependPreprompt": true,
  "variationalAutoencoder": "default"
}

Output

The output of the Generate Custom Images action is typically a URL pointing to the generated image. This allows developers to easily access and display the image in their applications.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/7d365dcc-2ed5-4a43-95cc-e66060c988fb/d96602d1-c718-424e-98fb-24803f8fe8b1.png"
]

Conceptual Usage Example (Python)

Here’s how you might structure a Python script to call the Generate Custom Images 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 = "2319579d-82b5-4223-8a77-6b92177df9ed"  # Action ID for Generate Custom Images

# Construct the input payload based on the action's requirements
payload = {
    "seed": -1,
    "model": "MiaoMiao-Harem-v1.5b",
    "steps": 30,
    "width": 1024,
    "height": 1024,
    "prompt": "street, 1girl, dark-purple short hair, purple eyes, medium breasts, cleavage, casual clothes, smile, V",
    "cfgScale": 6,
    "clipSkip": 2,
    "pagScale": 0,
    "batchSize": 1,
    "scheduler": "Euler a",
    "negativePrompt": "nsfw, naked",
    "guidanceRescale": 1,
    "prependPreprompt": True,
    "variationalAutoencoder": "default"
}

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, you substitute your API key and the endpoint URL. The payload is constructed using the example input provided, ensuring all necessary parameters are included. The response can then be parsed to fetch the generated image URL.

Conclusion

The Generate Custom Images action from the MiaoMiao-Harem v1.5b model offers an exciting way to integrate AI-driven image generation into your applications. By leveraging various parameters, you can create highly customized images that cater to your specific needs. Start experimenting with these Cognitive Actions today and unlock new creative possibilities in your projects!