Elevate Your App with Image Generation Using Kreezymind's AI Glasses Actions

23 Apr 2025
Elevate Your App with Image Generation Using Kreezymind's AI Glasses Actions

In this article, we will delve into the capabilities of Kreezymind's ai-glasses-rayban Cognitive Actions, specifically focusing on the Generate Enhanced Glasses Image action. This action allows developers to create high-quality images of glasses with customizable settings, leveraging advanced models for optimized speed and performance. By using these pre-built actions, developers can save significant time and effort, enhancing their applications with stunning visual content.

Prerequisites

Before integrating the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform, which will be used for authentication.
  • Familiarity with making HTTP requests in your programming environment.

For authentication, you would typically pass your API key in the request headers, allowing you to securely access the service.

Cognitive Actions Overview

Generate Enhanced Glasses Image

The Generate Enhanced Glasses Image action creates high-quality images of glasses by utilizing LoRA weights and customizable image settings. This action is particularly useful for applications that require visual representation and marketing materials for eyewear products.

Input

The input for this action requires a structured JSON object with the following fields:

  • prompt (required): A descriptive text prompt for image generation. Example: "aiglasses in front of a white background, product photoshoot, high quality".
  • mask (optional): An image mask for inpainting mode. Overrides dimensions if provided.
  • seed (optional): Integer for randomization, ensuring reproducibility.
  • image (optional): Input image for inpainting mode.
  • width (optional): Width of the generated image in pixels (256-1440).
  • height (optional): Height of the generated image in pixels (256-1440).
  • imageFormat (optional): Output format (default: "webp"). Example: "png".
  • outputCount (optional): Number of output images to generate (1-4).
  • sharedWeights (optional): Load LoRA weights from specified URLs.
  • enableFastMode (optional): Boolean to toggle fast generation.
  • imageMegapixels (optional): Estimated number of megapixels.
  • processingModel (optional): Select inference model (default: "dev").
  • imageAspectRatio (optional): Aspect ratio for the image (default: "1:1").
  • imageGuidanceScale (optional): Scale for diffusion guidance (default: 3).
  • imageOutputQuality (optional): Quality of output image (0-100, default: 80).
  • inferenceStepCount (optional): Number of denoising steps (default: 28).
  • loraIntensityScale (optional): Adjusts LoRA application strength (default: 1).
  • promptImpactStrength (optional): Strength of the prompt in image generation (default: 0.8).
  • additionalLoraWeights (optional): Load additional LoRA weights.
  • disableImageSafetyCheck (optional): Bypass safety checks for generated images.

Example Input:

{
  "prompt": "aiglasses in front of a white background, product photoshoot,\nhigh quality",
  "imageFormat": "png",
  "outputCount": 1,
  "processingModel": "dev",
  "imageAspectRatio": "4:5",
  "imageGuidanceScale": 3.5,
  "imageOutputQuality": 90,
  "inferenceStepCount": 28,
  "loraIntensityScale": 1,
  "promptImpactStrength": 0.8,
  "additionalLoraIntensityScale": 1
}

Output

The action typically returns a URL pointing to the generated image. Here’s an example of what the output might look like:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/8676eeff-8f03-4ee0-aaf5-37a3c1dad1c3/6bed02ec-966f-456c-8e61-32ed226414fd.png"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet illustrating how to call the Generate Enhanced Glasses Image action via a hypothetical 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 = "74e8a199-6d9f-4bf1-afdd-c5be3222d108"  # Action ID for Generate Enhanced Glasses Image

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "aiglasses in front of a white background, product photoshoot,\nhigh quality",
    "imageFormat": "png",
    "outputCount": 1,
    "processingModel": "dev",
    "imageAspectRatio": "4:5",
    "imageGuidanceScale": 3.5,
    "imageOutputQuality": 90,
    "inferenceStepCount": 28,
    "loraIntensityScale": 1,
    "promptImpactStrength": 0.8,
    "additionalLoraIntensityScale": 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, replace the YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the Generate Enhanced Glasses Image action. The payload is structured to include the necessary inputs, and the response will return the generated image URL.

Conclusion

The Generate Enhanced Glasses Image action from Kreezymind's ai-glasses-rayban Cognitive Actions offers developers a powerful tool for creating high-quality images tailored to their application's needs. With its customizable options and ease of integration, this action can significantly enhance user experience and engagement. Consider exploring additional use cases for this action, such as marketing campaigns or product catalogs, to fully leverage its capabilities. Happy coding!