Create Stunning Images with the "fiolinuda/fiona" Cognitive Actions

24 Apr 2025
Create Stunning Images with the "fiolinuda/fiona" Cognitive Actions

In the realm of image generation, the "fiolinuda/fiona" Cognitive Actions empower developers to create customized images with ease. This powerful API offers flexibility through inpainting and image-to-image modes, enabling users to manipulate various parameters for optimal results. Whether you're looking to generate unique visuals for your application or enhance existing images, these pre-built actions streamline the process and save time.

Prerequisites

Before diving into the integration of the "fiolinuda/fiona" Cognitive Actions, ensure you have the following prerequisites:

  • API Key: You will need an API key from the Cognitive Actions platform to authenticate your requests.
  • Endpoint Access: Familiarity with making API requests will aid in understanding how to interact with the Cognitive Actions API.

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

Cognitive Actions Overview

Generate Custom Image Using Inpainting

Description: This action generates customized images through inpainting or image-to-image modes, offering flexibility in aspect ratios, dimensions, and image quality. Users can leverage models 'dev' or 'schnell' for optimal speed and quality, adjustable via several parameters like prompt strength and guidance scale.

Input

The input for this action follows the structure outlined in the input_schema. Here’s a breakdown of the required and optional fields:

  • Required:
    • prompt: A text prompt to guide the image generation.
  • Optional:
    • mask: URI of an image mask used in inpainting mode.
    • seed: An integer seed for random number generation.
    • image: URI of the input image for image-to-image or inpainting mode.
    • width: Integer width of the generated image (must be between 256 and 1440).
    • height: Integer height of the generated image (must be between 256 and 1440).
    • goFast: Boolean to enable fast generation mode.
    • modelType: Selects the model for inference (options: "dev", "schnell").
    • Additional parameters such as numOutputs, outputFormat, guidanceScale, and more to customize the output.

Example Input:

{
  "prompt": "Fiona holding a sign at night. She is wearing a glow dress. Arrogant smile. Red lips, blondie strenght hair.",
  "loraScale": 1,
  "modelType": "dev",
  "numOutputs": 1,
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "imageAspectRatio": "3:4",
  "numInferenceSteps": 28
}

Output

Upon successful execution, the action typically returns a URL pointing to the generated image. Here’s an example of the output you can expect:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/ed308054-79db-4dc8-a09a-a7d278d1d846/14609541-6498-4957-8f99-2c0a92e14b26.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python snippet demonstrating how to call this action using the Cognitive Actions API:

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 = "f1965fd5-49c1-4f95-9ac1-74a7bbbc35af" # Action ID for Generate Custom Image Using Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "prompt": "Fiona holding a sign at night. She is wearing a glow dress. Arrogant smile. Red lips, blondie strenght hair.",
    "loraScale": 1,
    "modelType": "dev",
    "numOutputs": 1,
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "outputQuality": 90,
    "extraLoraScale": 1,
    "promptStrength": 0.8,
    "imageAspectRatio": "3:4",
    "numInferenceSteps": 28
}

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 the placeholders with your actual API key and endpoint. The action ID and input payload are structured according to the requirements of the "Generate Custom Image Using Inpainting" action.

Conclusion

The "fiolinuda/fiona" Cognitive Actions offer a robust solution for developers looking to create customized images effortlessly. With flexibility in image generation parameters and quick integration, these actions can enhance your applications and provide visually appealing outputs. Explore the potential of image generation in your projects and consider experimenting with the various parameters to achieve the best results!