Create Stunning Customized Images with Suffragettes Cognitive Actions

26 Apr 2025
Create Stunning Customized Images with Suffragettes Cognitive Actions

The Suffragettes Cognitive Actions provide developers with a powerful tool for generating customized images through advanced inpainting techniques. By leveraging the capabilities of this API, you can create visually striking images tailored to specific prompts and requirements, all while enjoying the benefits of speed and flexibility. Whether you're enhancing marketing materials, crafting social media content, or developing unique artistic projects, the Suffragettes actions simplify the image generation process, allowing you to focus on creativity rather than technical constraints.

Imagine a scenario where you need to create a compelling visual representation for a campaign advocating women's suffrage. With the ability to input detailed prompts and customize aspects like size, style, and quality, this API enables you to produce images that resonate with your audience effectively. The integration of various models allows you to choose the right balance between detail and performance, ensuring that your images are not only beautiful but also delivered promptly.

Generate Image with Inpainting and Customization

This action allows you to generate images using inpainting mode, which is particularly useful for creating or altering visual content based on specific requirements. By providing an image mask URI alongside various parameters, you can effectively control the output to meet your creative vision.

Input Requirements

To use this action, you need to provide several parameters:

  • Prompt: A descriptive text that guides the image generation process.
  • Mask (optional): A URI for an image mask, which can override other size settings.
  • Width and Height (optional): Specify dimensions for the generated image, particularly when using custom aspect ratios.
  • Model Version: Choose between 'dev' for detailed outputs or 'schnell' for faster generation.
  • Additional parameters: Such as guidance scale, prompt strength, and output format, to fine-tune your image.

Example input:

{
  "prompt": "old timey women are lined up outside woodrow wilson's white house picketing with signs for women's SUFFRAGE",
  "fastMode": false,
  "loraScale": 1,
  "modelVersion": "dev",
  "guidanceScale": 3,
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "numberOfOutputs": 1,
  "imageAspectRatio": "16:9",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

Expected Output

The output will be a URI link to the generated image, allowing you to access and use your customized creation seamlessly.

Example output:

[
  "https://assets.cognitiveactions.com/invocations/5f277646-9b63-43c3-be74-8e813a91d808/0dc51917-49e0-4650-8da9-77f5cbd95ef7.webp"
]

Use Cases for this Action

  • Marketing Campaigns: Generate unique visuals that align with your brand message or promotional content.
  • Social Media: Create eye-catching images that enhance engagement and resonate with your audience.
  • Content Creation: Develop custom illustrations for blogs, articles, or educational materials that require a unique visual touch.
  • Art Projects: Experiment with different styles and themes to create original artwork that reflects specific concepts or narratives.
import requests
import json

# Replace with your actual Cognitive Actions API key and endpoint
# Ensure your environment securely handles the API key
COGNITIVE_ACTIONS_API_KEY = "YOUR_COGNITIVE_ACTIONS_API_KEY"
# This endpoint URL is hypothetical and should be documented for users
COGNITIVE_ACTIONS_EXECUTE_URL = "https://api.cognitiveactions.com/actions/execute"

action_id = "ca31a1e6-d487-4608-92ae-2ec9747c0517" # Action ID for: Generate Image with Inpainting and Customization

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "prompt": "old timey women are lined up outside woodrow wilson's white house picketing with signs for women's SUFFRAGE",
  "fastMode": false,
  "loraScale": 1,
  "modelVersion": "dev",
  "guidanceScale": 3,
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "numberOfOutputs": 1,
  "imageAspectRatio": "16:9",
  "imageOutputFormat": "webp",
  "imageOutputQuality": 80,
  "additionalLoraScale": 1,
  "numberOfInferenceSteps": 28
}

headers = {
    "Authorization": f"Bearer {COGNITIVE_ACTIONS_API_KEY}",
    "Content-Type": "application/json",
    # Add any other required headers for the Cognitive Actions API
}

# Prepare the request body for the hypothetical execution endpoint
request_body = {
    "action_id": action_id,
    "inputs": payload
}

print(f"--- Calling Cognitive Action: {action.name or action_id} ---")
print(f"Endpoint: {COGNITIVE_ACTIONS_EXECUTE_URL}")
print(f"Action ID: {action_id}")
print("Payload being sent:")
print(json.dumps(request_body, indent=2))
print("------------------------------------------------")

try:
    response = requests.post(
        COGNITIVE_ACTIONS_EXECUTE_URL,
        headers=headers,
        json=request_body
    )
    response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)

    result = response.json()
    print("Action executed successfully. Result:")
    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 (non-JSON): {e.response.text}")
    print("------------------------------------------------")

In conclusion, the Suffragettes Cognitive Actions empower developers to create customized images that enhance their projects and meet specific creative needs. By understanding the input requirements and leveraging the flexibility of the API, you can produce stunning visuals that captivate your audience and effectively communicate your message. As you explore these capabilities, consider how they can fit into your workflow and lead to innovative applications in various fields.