Generate Stunning Images with Cognitive Actions from Fannie Lou Hamer

22 Apr 2025
Generate Stunning Images with Cognitive Actions from Fannie Lou Hamer

In the realm of image generation, the doctorparadox/fannie-lou-hamer Cognitive Actions offer a powerful toolset for developers looking to create unique and engaging visuals. The primary action available, Generate Image with Inpainting, leverages advanced techniques to create images based on user-defined prompts, allowing for significant customization and flexibility. This blog post will guide you through the capabilities of this action, its input requirements, output expectations, and how you can seamlessly integrate it into your applications.

Prerequisites

Before you start using the Cognitive Actions, ensure you have the following:

  • An API key for the Cognitive Actions platform.
  • Basic knowledge of JSON payload structure.
  • Familiarity with making HTTP requests in your preferred programming language.

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

Cognitive Actions Overview

Generate Image with Inpainting

Description:
The Generate Image with Inpainting action allows you to create images using inpainting techniques, providing options for custom dimensions and the use of masks. It offers various model selections for optimized speed and inference, allowing for multiple output formats and customization of attributes like aspect ratio, width, and height.

Category: Image Generation

Input

The action requires a JSON payload that includes several fields. Here are the necessary components:

  • prompt (required): A string that describes the image you want to generate.
  • goFast (optional): A boolean to enable faster predictions.
  • loraScale (optional): A number to adjust the intensity of the main LoRA application.
  • numOutputs (optional): An integer that specifies how many images to generate (default is 1).
  • guidanceScale (optional): A number that sets the guidance scale for the diffusion process.
  • outputQuality (optional): An integer that defines the quality level of the output image.
  • imageAspectRatio (optional): A string that defines the aspect ratio of the generated image.

Example Input:

{
  "goFast": false,
  "prompt": "FLH Fannie Lou Hamer speaking forcefully into a bullhorn at a rally",
  "loraScale": 1,
  "numOutputs": 4,
  "guidanceScale": 3,
  "outputQuality": 90,
  "extraLoraScale": 1,
  "inferenceModel": "dev",
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "webp",
  "numInferenceSteps": 28
}

Output

Upon successful execution, the action returns an array of URLs pointing to the generated images. Here’s what the output looks like:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/3eb862e2-6c8f-4c5c-ad14-c2f75b2d82b0/4149fe8f-06bf-4dcb-949d-d6830d16e8ea.webp",
  "https://assets.cognitiveactions.com/invocations/3eb862e2-6c8f-4c5c-ad14-c2f75b2d82b0/59ea73d3-849d-4902-a2c5-a952c8e8a03d.webp",
  "https://assets.cognitiveactions.com/invocations/3eb862e2-6c8f-4c5c-ad14-c2f75b2d82b0/7b02e3e1-871d-4163-bf20-3b4171cd1a26.webp",
  "https://assets.cognitiveactions.com/invocations/3eb862e2-6c8f-4c5c-ad14-c2f75b2d82b0/fd6027bb-3123-4af7-aba8-03d4b478fd94.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet to demonstrate how to call the Cognitive Actions execution endpoint with the above input:

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 = "eb8c8857-296b-43b9-b555-e4663b716dee"  # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "goFast": False,
    "prompt": "FLH Fannie Lou Hamer speaking forcefully into a bullhorn at a rally",
    "loraScale": 1,
    "numOutputs": 4,
    "guidanceScale": 3,
    "outputQuality": 90,
    "extraLoraScale": 1,
    "inferenceModel": "dev",
    "promptStrength": 0.8,
    "imageMegapixels": "1",
    "imageAspectRatio": "1:1",
    "imageOutputFormat": "webp",
    "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 YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The payload contains the input data structured according to the action's requirements.

Conclusion

The Generate Image with Inpainting action from the doctorparadox/fannie-lou-hamer spec provides a robust solution for developers looking to create customized images through simple API calls. By utilizing this action, you can enhance your applications with unique visuals tailored to specific prompts, all while enjoying the benefits of rapid image generation and customization. Start experimenting with this action today and unlock the potential of image generation in your projects!