Enhance Your Applications with Image Generation Using likolibardi/2frankguemes Cognitive Actions

23 Apr 2025
Enhance Your Applications with Image Generation Using likolibardi/2frankguemes Cognitive Actions

In the rapidly evolving world of artificial intelligence, image generation has become a fascinating area of exploration. The likolibardi/2frankguemes spec offers a powerful Cognitive Action that allows developers to generate images using advanced inpainting techniques. By leveraging this action, you can create high-quality images tailored to specific user inputs, making it ideal for applications in creative industries, marketing, and content creation. This article will guide you through the capabilities of the Generate Image with Inpainting action, detailing how to integrate it into your own applications effectively.

Prerequisites

Before you start using the Cognitive Actions from the likolibardi/2frankguemes spec, ensure you have the following:

  • An API key for the Cognitive Actions platform to authenticate your requests.
  • Basic knowledge of JSON and how to work with APIs.
  • Familiarity with Python and the requests library for making HTTP requests.

Authentication typically involves passing your API key in the request headers, which will be illustrated in the following examples.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action enables developers to generate images based on user-defined prompts and customizable parameters. This action supports various model selections and quality settings, allowing for flexibility and precision in image creation.

  • Category: image-generation

Input

The input schema for this action requires a prompt and supports multiple optional parameters. Below is a breakdown of the required and optional fields:

  • Required:
    • prompt: A string that describes the desired image. For example, "2frankguemes stands alone in a miami beach shore wearing a beige suit, looking to the camera".
  • Optional:
    • mask: URI of an image mask for inpainting.
    • seed: Integer for reproducible generation.
    • image: URI of an input image for image-to-image or inpainting mode.
    • model: Choice between "dev" or "schnell" (default is "dev").
    • width: Width of the output image (must be a multiple of 16).
    • height: Height of the output image (must be a multiple of 16).
    • aspectRatio: Defines the aspect ratio of the output image (default is "1:1").
    • Additional parameters related to quality, guidance, and LoRA weights can also be specified.

Example Input:

{
  "model": "dev",
  "width": 810,
  "height": 1440,
  "prompt": "2frankguemes stands alone in a miami beach shore wearing a beige suit, looking to the camera",
  "loraScale": 1,
  "megapixels": "1",
  "aspectRatio": "9:16",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "promptStrength": 0.8,
  "numberOfOutputs": 4,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28,
  "enableSpeedOptimization": false
}

Output

The action typically returns an array of URLs pointing to the generated images. The output format can vary based on the chosen parameters, but you can expect high-quality image files in the specified format.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/d20625a1-6bc0-4ec6-933c-0a3d89a4d29e/33bdc6a3-cf3c-4ee0-9013-bc602357e364.webp",
  "https://assets.cognitiveactions.com/invocations/d20625a1-6bc0-4ec6-933c-0a3d89a4d29e/0ab9c153-26d2-4bfc-9f7f-73c851d1acd7.webp",
  "https://assets.cognitiveactions.com/invocations/d20625a1-6bc0-4ec6-933c-0a3d89a4d29e/1fabddef-8913-4d09-b01c-dbbb072f5910.webp",
  "https://assets.cognitiveactions.com/invocations/d20625a1-6bc0-4ec6-933c-0a3d89a4d29e/6b32178d-7eb8-4b17-ab7f-636e688946c8.webp"
]

Conceptual Usage Example (Python)

Here is a conceptual Python code snippet demonstrating how to call the Generate Image with Inpainting action. This example focuses on structuring the input JSON payload correctly:

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 = "0615bb20-8c99-4669-8fc4-35c0f2d2bddf"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 810,
    "height": 1440,
    "prompt": "2frankguemes stands alone in a miami beach shore wearing a beige suit, looking to the camera",
    "loraScale": 1,
    "megapixels": "1",
    "aspectRatio": "9:16",
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "promptStrength": 0.8,
    "numberOfOutputs": 4,
    "additionalLoraScale": 1,
    "numberOfInferenceSteps": 28,
    "enableSpeedOptimization": False
}

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 action_id corresponds to the action you wish to execute. The payload is structured according to the specified input schema. Remember, the endpoint URL and request structure provided here are illustrative.

Conclusion

The Generate Image with Inpainting action from the likolibardi/2frankguemes spec offers a robust solution for developers looking to incorporate high-quality image generation into their applications. By customizing parameters such as aspect ratio, quality, and model selection, you can create images that resonate with your audience and meet your project's specific needs.

Start integrating these Cognitive Actions today to elevate your application's capabilities and unleash your creativity!