Transform Your Images with the andyx1976/ivograham Cognitive Actions

24 Apr 2025
Transform Your Images with the andyx1976/ivograham Cognitive Actions

In the evolving landscape of image generation and manipulation, the andyx1976/ivograham Cognitive Actions provide powerful tools that leverage advanced techniques like inpainting and model selection. These actions enable developers to create high-quality, customized images with a variety of parameters, ensuring flexibility and control over the output. Whether you are building a creative application, enhancing content, or simply experimenting with image generation, these actions can significantly streamline your workflow.

Prerequisites

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

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of sending HTTP requests and handling JSON data in your programming environment.

Authentication typically involves passing your API key in the request headers.

Cognitive Actions Overview

Generate Enhanced Images

Purpose:
The "Generate Enhanced Images" action allows you to transform input images using advanced inpainting and generation techniques. You can select from different models, adjust various parameters, and produce personalized images with high quality. This action is especially useful for applications requiring image customization and creative content generation.

Category: Image Generation

Input:

  • Required Fields:
    • prompt: A text prompt guiding the image generation.
  • Optional Fields:
    • mask: URI for the image mask used in inpainting mode.
    • seed: Seed value for random number generation.
    • image: URI for the input image.
    • width: Width of the output image in pixels (when aspect_ratio is 'custom').
    • height: Height of the output image in pixels (when aspect_ratio is 'custom').
    • goFast: Optimize for faster predictions.
    • numOutputs: Number of images to generate (1 to 4).
    • guidanceScale: Adjusts guidance in the diffusion process.
    • outputQuality: Image quality for output formats.
    • inferenceModel: Selects the inference model type ('dev' or 'schnell').
    • And several others for fine-tuning generation.

Example Input JSON:

{
  "goFast": false,
  "prompt": "young man, sim skinny, iivo, slim and skinny, looks at the camera, wearing a wide open dress shirt, revealing his very hairy chest.",
  "loraScale": 1,
  "numOutputs": 1,
  "guidanceScale": 3,
  "outputQuality": 100,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "imageAspectRatio": "3:4",
  "imageOutputFormat": "jpg",
  "numInferenceSteps": 21
}

Output: The action typically returns a URL pointing to the generated image.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/b837f119-2e18-4e57-989f-40311c76a28f/a4ea9c81-487c-4002-b380-1d8eba73d5c7.jpg"
]

Conceptual Usage Example (Python): Here's how you might call the "Generate Enhanced Images" action using Python:

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 = "0a5acf0c-6585-402f-90aa-a6941cb2ddcf"  # Action ID for Generate Enhanced Images

# Construct the input payload based on the action's requirements
payload = {
    "goFast": False,
    "prompt": "young man, sim skinny, iivo, slim and skinny, looks at the camera, wearing a wide open dress shirt, revealing his very hairy chest.",
    "loraScale": 1,
    "numOutputs": 1,
    "guidanceScale": 3,
    "outputQuality": 100,
    "extraLoraScale": 1,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "imageAspectRatio": "3:4",
    "imageOutputFormat": "jpg",
    "numInferenceSteps": 21
}

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}")

Conclusion

The andyx1976/ivograham Cognitive Actions, particularly the "Generate Enhanced Images" action, empower developers to create stunning, customized images. With its robust parameters and flexibility, you can tailor image generation to fit your application's needs. Start experimenting with these actions and unlock new creative possibilities for your projects!