Revolutionize Your App's Image Generation with bymobrand/oneyy Cognitive Actions

21 Apr 2025
Revolutionize Your App's Image Generation with bymobrand/oneyy Cognitive Actions

In today’s rapidly advancing tech landscape, the ability to generate high-quality images programmatically can enhance user experience and create innovative applications. The bymobrand/oneyy Cognitive Actions provide developers with a powerful tool to harness image generation capabilities using advanced techniques like image-to-image transformation and inpainting. With customizable options for quality, aspect ratios, and models, these actions allow for versatile and engaging applications in various domains.

Prerequisites

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

  • An API key from the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON format, as the input and output will be structured in this way.

Authentication typically involves passing your API key in the request headers, allowing you to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with Mask

Description:
The "Generate Image with Mask" action allows developers to create images using sophisticated image processing techniques. Whether you want to generate new images from prompts or modify existing ones, this action supports fast image generation while optimizing aspects like inference steps for enhanced speed and quality.

Category: Image Processing

Input

The following fields are required or optional based on the input schema:

  • prompt (required): A detailed description of the image to be generated.
  • mask (optional): An image mask used for inpainting mode. If provided, it will ignore the width, height, and aspect ratio inputs.
  • seed (optional): A random seed for reproducibility.
  • image (optional): An input image for image-to-image or inpainting mode.
  • model (optional): Specify either "dev" or "schnell" for different inference optimizations.
  • width (optional): Width of the generated image (only for custom aspect ratios).
  • height (optional): Height of the generated image (only for custom aspect ratios).
  • loraScale (optional): Intensity of the main LoRA application.
  • megapixels (optional): Number of megapixels for the generated image.
  • aspectRatio (optional): Defines the aspect ratio of the generated image.
  • outputFormat (optional): Desired format for output images (webp, jpg, png).
  • guidanceScale (optional): Scale for guiding the image generation.
  • outputQuality (optional): Determines quality from 0 to 100.
  • enableFastMode (optional): Toggle for fast predictions.
  • outputQuantity (optional): Number of images to generate.
  • promptStrength (optional): Strength of the prompt when using image-to-image.
  • numInferenceSteps (optional): Steps for denoising (more steps yield more detail).
  • disableSafetyChecker (optional): Option to disable safety checks.
  • additionalLoraWeights (optional): Load supplementary LoRA weights.

Example Input:

{
  "model": "dev",
  "prompt": "oneyaraujo A confident man with dark, slightly tousled hair sits in a luxurious dark blue armchair against a solid dark background. He wears a navy blue blazer over a black shirt, paired with black pants and black leather loafers. His posture is relaxed yet assertive, with one leg crossed over the other and arms resting on the chair’s armrests. His expression is composed and slightly enigmatic, exuding authority and sophistication. The lighting is soft and moody, casting subtle shadows that enhance the subject's strong facial features and the texture of his attire. The overall atmosphere is modern, elegant, and slightly cinematic.",
  "loraScale": 1,
  "megapixels": "1",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3,
  "outputQuality": 80,
  "enableFastMode": false,
  "outputQuantity": 1,
  "promptStrength": 0.8,
  "numInferenceSteps": 28,
  "additionalLoraStrength": 1
}

Output

The action returns a URL pointing to the generated image output. Here’s an example of a possible output:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/10b7f32a-6b43-4031-83d8-b3cc99303384/a5142fce-76a1-43a1-80e8-7b404524ab5a.webp"
]

Conceptual Usage Example (Python)

Here’s a Python snippet to demonstrate how to invoke the "Generate Image with Mask" 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 = "899dc251-9375-4066-a621-3d07ca182fde" # Action ID for Generate Image with Mask

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "oneyaraujo A confident man with dark, slightly tousled hair sits in a luxurious dark blue armchair against a solid dark background. He wears a navy blue blazer over a black shirt, paired with black pants and black leather loafers. His posture is relaxed yet assertive, with one leg crossed over the other and arms resting on the chair’s armrests. His expression is composed and slightly enigmatic, exuding authority and sophistication. The lighting is soft and moody, casting subtle shadows that enhance the subject's strong facial features and the texture of his attire. The overall atmosphere is modern, elegant, and slightly cinematic.",
    "loraScale": 1,
    "megapixels": "1",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3,
    "outputQuality": 80,
    "enableFastMode": false,
    "outputQuantity": 1,
    "promptStrength": 0.8,
    "numInferenceSteps": 28,
    "additionalLoraStrength": 1
}

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 snippet, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload is structured according to the input schema. The action ID corresponds to the "Generate Image with Mask" action.

Conclusion

The bymobrand/oneyy Cognitive Actions provide developers with powerful tools to generate and manipulate images efficiently. By leveraging these actions, you can create unique visual content tailored to your application's needs. Whether you’re looking to generate images from text prompts or refine existing visuals, the options available are designed to enhance creativity and productivity. Start integrating these actions into your application today and unlock new potential!