Create Stunning Images with the mikeymike1984/face Cognitive Actions

22 Apr 2025
Create Stunning Images with the mikeymike1984/face Cognitive Actions

In today's digital landscape, the ability to create and modify images effectively can greatly enhance applications, from content creation to marketing. The mikeymike1984/face Cognitive Actions provide powerful tools for image processing, specifically through the action of generating custom inpainting images. This action allows developers to create unique images using advanced techniques with customizable parameters, making it an excellent addition to any application that requires image manipulation.

Prerequisites

Before diving into the integration of the Cognitive Actions, ensure you have the following prerequisites in place:

  • API Key: You need a valid API key for accessing the Cognitive Actions platform.
  • Basic Setup: Familiarity with making HTTP requests and handling JSON responses will be beneficial.

For authentication, you'll typically pass the API key in the request headers to authenticate your requests.

Cognitive Actions Overview

Generate Custom Inpainting Image

The Generate Custom Inpainting Image action allows you to create custom images through inpainting. You can choose between two models: a detailed generation model (dev) or a faster model (schnell). This action supports various configurations, such as aspect ratio and output format, and leverages image masks for precise modifications.

Input

The input schema for this action requires a JSON object that includes the following fields:

  • prompt (required): A string that dictates what the generated image should depict.
  • mask (optional): A string URI for an image mask used for inpainting; if provided, dimensions are ignored.
  • seed (optional): An integer for reproducibility.
  • image (optional): An input image URI for image-to-image or inpainting mode; dimensions will be ignored if provided.
  • model (optional): Specifies the inference model, either dev (default) or schnell.
  • width (optional): Specifies the image width (only if aspect_ratio is custom).
  • height (optional): Specifies the image height (only if aspect_ratio is custom).
  • goFast (optional): A boolean to enable faster predictions.
  • aspectRatio (optional): Determines the image's aspect ratio.
  • imageFormat (optional): Specifies the output format (e.g., webp, jpg, png).
  • imageQuality (optional): An integer indicating output image quality.
  • numberOfOutputs (optional): Specifies how many output images to generate.
  • inferenceSteps (optional): Defines the number of denoising steps for the generation process.

Example Input:

{
  "model": "dev",
  "goFast": false,
  "prompt": "photo of mike wearing nice formal wear and walking down the streets of downtown Fort Worth, Texas.",
  "megapixels": "1",
  "aspectRatio": "1:1",
  "imageFormat": "webp",
  "imageQuality": 80,
  "loraIntensity": 1,
  "inferenceSteps": 28,
  "numberOfOutputs": 1,
  "promptIntensity": 0,
  "guidanceIntensity": 3,
  "additionalLoraIntensity": 1
}

Output

Upon successful execution, this action typically returns an array of URLs pointing to the generated images. Here’s an example of the output you might receive:

Example Output:

[
  "https://assets.cognitiveactions.com/invocations/6c0656df-9e4f-426b-8387-96255954b261/7e9ef3d5-bab6-4bbb-a517-ba431bbf69a2.webp"
]

Conceptual Usage Example (Python)

Below is a conceptual Python code snippet demonstrating how to invoke the Generate Custom Inpainting Image 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 = "4244b83e-05cf-4636-b801-c8ca3b94f0a8" # Action ID for Generate Custom Inpainting Image

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "goFast": False,
    "prompt": "photo of mike wearing nice formal wear and walking down the streets of downtown Fort Worth, Texas.",
    "megapixels": "1",
    "aspectRatio": "1:1",
    "imageFormat": "webp",
    "imageQuality": 80,
    "loraIntensity": 1,
    "inferenceSteps": 28,
    "numberOfOutputs": 1,
    "promptIntensity": 0,
    "guidanceIntensity": 3,
    "additionalLoraIntensity": 1
}

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, replace YOUR_COGNITIVE_ACTIONS_API_KEY with your actual API key. The action ID is used to specify which action you want to execute, and the payload structure is built according to the required input schema.

Conclusion

The mikeymike1984/face Cognitive Actions provide developers with robust capabilities for generating custom images through inpainting. By leveraging these actions, you can enhance your applications' visual appeal and functionality. Consider exploring additional use cases such as integrating image generation in creative applications, marketing tools, or social media platforms. Dive into the possibilities and start creating stunning images today!