Generate Stunning Images with the anton-uperenko-ew/antonio Cognitive Actions

24 Apr 2025
Generate Stunning Images with the anton-uperenko-ew/antonio Cognitive Actions

In the world of artificial intelligence, generating images has become increasingly sophisticated. The anton-uperenko-ew/antonio API provides developers with powerful Cognitive Actions to create stunning visuals using advanced techniques like LoRA (Low-Rank Adaptation). These pre-built actions allow for customizable settings, making it easier than ever to integrate image generation capabilities into your applications.

Prerequisites

To get started with the Cognitive Actions from the anton-uperenko-ew/antonio API, you'll need to ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic understanding of making HTTP requests and handling JSON payloads.
  • Familiarity with Python programming to leverage the example code provided within this guide.

Authentication typically involves passing the API key in the headers of your requests to securely access the Cognitive Actions.

Cognitive Actions Overview

Generate Image with LoRA Settings

Description: This action generates an image using advanced LoRA techniques with customizable settings for image resolution, aspect ratio, guidance scale, and additional LoRA weights. It supports inpainting, image-to-image transformations, and quick predictions through a fast mode.

Category: Image Generation

Input

The input to this action requires a JSON object containing various fields. Here’s a breakdown of the required and optional properties:

  • Required:
    • prompt: A text description for generating the image.
  • Optional:
    • mask: URI of the image mask for inpainting mode.
    • seed: Integer for generating reproducible results.
    • image: URI of the input image for transformations.
    • model: Specifies the model to use (dev or schnell).
    • width: Width of the generated image.
    • goFast: Enables faster predictions.
    • height: Height of the generated image.
    • extraLora: URI for extra LoRA weights.
    • loraScale: Strength of the main LoRA application.
    • megapixels: Approximate number of megapixels for the image.
    • outputCount: Number of output images to generate.
    • imageAspectRatio: Aspect ratio of the image.
    • imageOutputFormat: Format of the output image (e.g., webp, jpg, png).
    • denoisingStepCount: Steps for denoising the image.
    • imageOutputQuality: Quality of the output images.
    • additionalLoraScale: Strength for applying extra LoRA.
    • imagePromptStrength: Influence of the prompt in img2img mode.
    • safetyCheckerDisabled: Skips the safety checker if enabled.
    • diffusionGuidanceScale: Guidance scale for the diffusion process.

Example Input:

{
  "model": "dev",
  "prompt": "Image of antonio as Guts from Berserk in anime style",
  "loraScale": 1,
  "outputCount": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "denoisingStepCount": 28,
  "imageOutputQuality": 90,
  "additionalLoraScale": 1,
  "imagePromptStrength": 0.8,
  "diffusionGuidanceScale": 3.5
}

Output

The action typically returns a URL to the generated image based on the specified prompt and settings.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/825c5180-3b79-48af-969f-8e7e01251863/09d65de1-da6a-4b68-be4d-523c501b3abb.webp"
]

Conceptual Usage Example (Python)

Here’s how a developer might call the Generate Image with LoRA Settings 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 = "982d45f6-24de-4d20-af00-022d020dde81" # Action ID for Generate Image with LoRA Settings

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "Image of antonio as Guts from Berserk in anime style",
    "loraScale": 1,
    "outputCount": 1,
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "denoisingStepCount": 28,
    "imageOutputQuality": 90,
    "additionalLoraScale": 1,
    "imagePromptStrength": 0.8,
    "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 snippet, you replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload variable is constructed according to the action's schema, and the request is sent to a hypothetical endpoint.

Conclusion

The anton-uperenko-ew/antonio Cognitive Actions open up exciting possibilities for developers looking to implement advanced image generation capabilities in their applications. By leveraging these actions, you can create highly customizable images with minimal effort. Start experimenting with various parameters and use cases to unlock the full potential of your creativity!