Create Stunning Images with Inpainting Using the CygnetBottle3_21 Actions

23 Apr 2025
Create Stunning Images with Inpainting Using the CygnetBottle3_21 Actions

In the ever-evolving landscape of artificial intelligence, the ability to generate images has become a powerful tool for developers. The CygnetBottle3_21 spec provides a robust set of Cognitive Actions that enable users to create detailed images through inpainting, along with various customization options. These pre-built actions streamline the image generation process, allowing developers to focus on creativity rather than technical complexities.

Prerequisites

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

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of sending HTTP requests.
  • Familiarity with JSON formatting for input/output structures.

Authentication typically involves passing your API key in the headers of your requests.

Cognitive Actions Overview

Generate Image with Inpainting

The Generate Image with Inpainting action allows developers to create detailed images using a provided prompt and optional customizations like aspect ratio and LoRA weights. This action is categorized under image-generation.

Input

The input schema for this action requires the following fields:

  • prompt (required): A descriptive text prompt guiding the image generation.
  • model (optional): Specifies the inference model. Options include "dev" (default) and "schnell".
  • width (optional): The width of the generated image, applicable only if 'aspect_ratio' is set to 'custom'.
  • height (optional): The height of the generated image, also applicable only if 'aspect_ratio' is 'custom'.
  • goFast (optional): A boolean to enable faster predictions. Default is false.
  • numOutputs (optional): Specifies the number of image outputs to generate (default is 1).
  • guidanceScale (optional): Controls the guidance scale during the diffusion process (default is 3).
  • outputQuality (optional): Specifies the quality level for saving output images (default is 80).
  • numInferenceSteps (optional): Controls the number of denoising steps during image generation (default is 28).
  • Additional options for further customization such as extraLora, loraScale, imageAspectRatio, and imageOutputFormat.

Here’s an example input JSON payload:

{
  "model": "dev",
  "width": 1375,
  "goFast": false,
  "height": 900,
  "prompt": "A bottle of CYG and a glass of whiskey on a glass table, with an ocean view in the background. The evening light casts a warm glow, creating an editorial photography-style scene.",
  "loraScale": 1,
  "numOutputs": 1,
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "numInferenceSteps": 38
}

Output

On successful execution, the action returns a list of generated image URLs. Here’s a sample output:

[
  "https://assets.cognitiveactions.com/invocations/0724417e-8c4e-4c20-bce0-0435fb5453db/ad99b125-d6c1-4084-a8e7-ba3213ca5973.png"
]

Conceptual Usage Example (Python)

Here’s how a developer might call the Generate Image with Inpainting 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 = "bcf27ccf-e5ec-4a24-bf1f-0d7fcc99e3d9"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "width": 1375,
    "goFast": False,
    "height": 900,
    "prompt": "A bottle of CYG and a glass of whiskey on a glass table, with an ocean view in the background. The evening light casts a warm glow, creating an editorial photography-style scene.",
    "loraScale": 1,
    "numOutputs": 1,
    "guidanceScale": 3.5,
    "outputQuality": 80,
    "numInferenceSteps": 38
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action_id corresponds to the Generate Image with Inpainting action. The input payload is structured according to the requirements outlined above.

Conclusion

The CygnetBottle3_21 spec provides a powerful toolset for generating stunning images through the Cognitive Actions platform. By leveraging the Generate Image with Inpainting action, developers can create unique visuals tailored to their specific needs. Whether for applications in marketing, design, or entertainment, the possibilities are endless. Start experimenting with these actions today and see where your creativity takes you!