Generate Stunning Images with markbland82/mjbstyle1 Cognitive Actions

23 Apr 2025
Generate Stunning Images with markbland82/mjbstyle1 Cognitive Actions

In today's digital landscape, the ability to generate high-quality images efficiently is a game-changer for developers. The markbland82/mjbstyle1 spec provides a powerful Cognitive Action designed to enhance image generation through advanced inpainting techniques. This action allows developers to create stunning imagery tailored to specific needs, utilizing customizable settings for optimal performance. With the ability to generate images that reflect intricate details and artistic styles, these pre-built actions can save developers valuable time and resources.

Prerequisites

Before diving into the integration of Cognitive Actions, ensure you have the following:

  • An API key for accessing the Cognitive Actions platform.
  • Familiarity with basic JSON structure and HTTP requests.
  • A conceptual understanding of how to authenticate API calls, typically by passing your API key in the headers.

Cognitive Actions Overview

Generate Enhanced Image

The Generate Enhanced Image action is designed to create high-quality images using advanced techniques. It supports various customizable settings, such as dimensions, aspect ratios, and output formats. This action leverages models that optimize performance and can incorporate additional weights for enhanced results.

Input

The input schema for this action requires a JSON object with the following properties:

  • prompt (required): A detailed description of what the generated image should depict.
  • mask (optional): An image mask for inpainting mode.
  • seed (optional): A random seed for reproducible generation.
  • image (optional): An input image for inpainting or image-to-image generation.
  • model (optional): Select between "dev" and "schnell" models, defaulting to "dev".
  • width (optional): Width of the generated image (valid only if aspect ratio is custom).
  • height (optional): Height of the generated image (valid only if aspect ratio is custom).
  • imageAspectRatio (optional): Specifies the aspect ratio for the image.
  • numberOfOutputs (optional): The number of images to generate (1-4).
  • imageOutputFormat (optional): Format of the output image (e.g., "webp", "jpg", "png").
  • imageOutputQuality (optional): Quality of the output image (0-100).
  • additionalLoraScale (optional): Scale for additional LoRA weights.
  • loraApplicationScale (optional): Scale for the main LoRA.
  • numberOfDenosingSteps (optional): Number of denoising steps for image quality.
  • diffusionGuidanceScale (optional): Guidance scale for the diffusion process.

Example Input:

{
  "model": "dev",
  "prompt": "1MARK1, A close-up view of a butterfly wing captured through scanning electron microscopy, showcasing the intricate scales and their unique patterns. The image reveals the microscopic texture and the overlapping layers, resembling a detailed mosaic. The monochromatic tones enhance the fine structures, giving the scene an abstract, otherworldly feel. (Medium: digital micrograph) (Style: inspired by scientific photography and abstract art) (Lighting: high-contrast lighting to emphasize textures and depth) (Colors: monochrome, grayscale with high contrast) (Composition: extreme close-up shot using an FEI Quanta 250 SEM, focusing on a specific area of the wing to highlight the repetitive patterns and textures.)",
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraScale": 0.8,
  "loraApplicationScale": 1,
  "numberOfDenosingSteps": 28,
  "diffusionGuidanceScale": 3.5
}

Output

The output typically consists of a URL pointing to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/20e923ab-a3d9-455d-b16c-8e8ce869fb31/bf7ceef2-f567-4766-ad49-d635efb0b720.webp"
]

This URL can be used to display or download the generated image.

Conceptual Usage Example (Python)

Here’s a conceptual Python snippet to illustrate how you might call the Cognitive Actions execution endpoint:

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 = "250bad1f-cd6c-41e8-a0c6-c5560f562a50"  # Action ID for Generate Enhanced Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "1MARK1, A close-up view of a butterfly wing captured through scanning electron microscopy, showcasing the intricate scales and their unique patterns. The image reveals the microscopic texture and the overlapping layers, resembling a detailed mosaic. The monochromatic tones enhance the fine structures, giving the scene an abstract, otherworldly feel. (Medium: digital micrograph) (Style: inspired by scientific photography and abstract art) (Lighting: high-contrast lighting to emphasize textures and depth) (Colors: monochrome, grayscale with high contrast) (Composition: extreme close-up shot using an FEI Quanta 250 SEM, focusing on a specific area of the wing to highlight the repetitive patterns and textures.)",
    "numberOfOutputs": 1,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "imageOutputQuality": 80,
    "additionalLoraScale": 0.8,
    "loraApplicationScale": 1,
    "numberOfDenosingSteps": 28,
    "diffusionGuidanceScale": 3.5
}

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 the placeholders with your API key and the relevant endpoint. The input payload is structured according to the requirements of the Generate Enhanced Image action.

Conclusion

The markbland82/mjbstyle1 Cognitive Action provides developers with a powerful tool for generating high-quality images tailored to specific needs. By leveraging customizable parameters and advanced inpainting techniques, developers can create stunning visuals that enhance applications across various domains. Explore the capabilities of this action and consider integrating it into your projects to elevate your image generation processes.