Transform Your Images with the stasdeep/superside-demo Cognitive Actions

23 Apr 2025
Transform Your Images with the stasdeep/superside-demo Cognitive Actions

In the realm of artificial intelligence and image processing, the ability to generate and manipulate images has become increasingly accessible to developers through various APIs. The stasdeep/superside-demo provides a powerful set of Cognitive Actions designed specifically for image generation tasks, including innovative features like inpainting and fine-tuning options. By leveraging these pre-built actions, developers can streamline their image processing workflows, saving time and resources while producing high-quality outputs.

Prerequisites

To start using the Cognitive Actions from the stasdeep/superside-demo, you'll need an API key from the Cognitive Actions platform. This key serves as a means of authentication, allowing your application to access the image generation services. Typically, you'll include this key in the request headers when making API calls.

Cognitive Actions Overview

Generate Image with Inpainting

This action allows you to generate images with the ability to inpaint using a specified mask. It offers various parameters to customize image dimensions, seed generation, and more, enabling you to fine-tune your outputs effectively.

Input

The following JSON schema outlines the required and optional fields for this action:

{
  "mask": "string (uri)",
  "seed": "integer",
  "image": "string (uri)",
  "width": "integer (default: 1024)",
  "height": "integer (default: 1024)",
  "prompt": "string (default: 'An astronaut riding a rainbow unicorn')",
  "loraScale": "number (default: 0.6, range: 0-1)",
  "loraWeights": "string",
  "outputCount": "integer (default: 1, range: 1-4)",
  "refineSteps": "integer",
  "refineStyle": "string (default: 'no_refiner')",
  "guidanceScale": "number (default: 7.5, range: 1-50)",
  "highNoiseFrac": "number (default: 0.8, range: 0-1)",
  "applyWatermark": "boolean (default: true)",
  "negativePrompt": "string (default: '')",
  "promptStrength": "number (default: 0.8, range: 0-1)",
  "schedulingMethod": "string (default: 'K_EULER')",
  "numInferenceSteps": "integer (default: 50, range: 1-500)",
  "disableSafetyChecker": "boolean (default: false)"
}

Example Input:

{
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of TOK, vector illustration of a man in a space suit pushing a shopping cart",
  "loraScale": 0.85,
  "outputCount": 1,
  "refineStyle": "expert_ensemble_refiner",
  "guidanceScale": 7.5,
  "highNoiseFrac": 0.8,
  "applyWatermark": true,
  "negativePrompt": "ugly, broken, disfigured, people",
  "promptStrength": 0.8,
  "schedulingMethod": "K_EULER",
  "numInferenceSteps": 50
}

Output

The output of this action typically returns a list of image URLs generated based on the provided parameters.

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/d1f20671-3da4-4ab4-af7f-35a4cdb23191/559fc0b5-6715-4f91-9fd3-e22aed5038be.png"
]

Conceptual Usage Example (Python)

Here’s how a developer might call the Cognitive Actions execution endpoint for the Generate Image with Inpainting action:

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 = "a6e3ce6d-62a8-4355-aa24-45a53cab04d4" # Action ID for Generate Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "width": 1024,
    "height": 1024,
    "prompt": "In the style of TOK, vector illustration of a man in a space suit pushing a shopping cart",
    "loraScale": 0.85,
    "outputCount": 1,
    "refineStyle": "expert_ensemble_refiner",
    "guidanceScale": 7.5,
    "highNoiseFrac": 0.8,
    "applyWatermark": true,
    "negativePrompt": "ugly, broken, disfigured, people",
    "promptStrength": 0.8,
    "schedulingMethod": "K_EULER",
    "numInferenceSteps": 50
}

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 example, the action_id corresponds to the Generate Image with Inpainting action, and the payload is structured according to the input requirements detailed above. This code illustrates how to send a request to the Cognitive Actions API and handle the response.

Conclusion

The stasdeep/superside-demo Cognitive Actions present a robust solution for developers looking to incorporate advanced image generation capabilities into their applications. By utilizing the Generate Image with Inpainting action, you can create tailored images with a high degree of customization. Whether you're building creative applications or enhancing user experiences, these actions open up a wealth of possibilities in the realm of image processing. Start experimenting with these tools today to unlock new creative potentials!