Create Custom Images with Inpainting Using maczzzzzzz/pixolpepe Cognitive Actions

21 Apr 2025
Create Custom Images with Inpainting Using maczzzzzzz/pixolpepe Cognitive Actions

In the ever-evolving landscape of image generation, the maczzzzzzz/pixolpepe Cognitive Actions empower developers with the ability to create stunning custom images through advanced inpainting and image-to-image generation techniques. These pre-built actions simplify the integration of complex functionalities, enabling you to focus on your application while leveraging sophisticated image generation capabilities. Let's explore how you can harness these actions effectively.

Prerequisites

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

  1. API Key: You'll need a valid API key for accessing the Cognitive Actions platform.
  2. Basic Setup: Familiarity with making HTTP requests and handling JSON data is essential.

Authentication is generally handled by including the API key in the request headers, allowing secure access to the functionalities provided by the Cognitive Actions.

Cognitive Actions Overview

Generate Custom Image with Inpainting

This action allows you to create custom images using specified attributes such as aspect ratio, quality, and format. With various configurations, you can fine-tune image characteristics, including prompt influence and resolution.

Input

The input schema for this action requires the following fields:

  • prompt (required): A text description guiding the image generation.
  • mask (optional): A URI for an image mask used in inpainting mode.
  • seed (optional): An integer to generate reproducible results.
  • image (optional): A URI for an input image used in translation or inpainting mode.
  • model (optional): Choose between "dev" or "schnell" for model selection.
  • width (optional): Width of the image (if aspect_ratio is 'custom').
  • height (optional): Height of the image (if aspect_ratio is 'custom').
  • aspectRatio (optional): Defines the aspect ratio of the generated image.
  • outputFormat (optional): Specify the output format (e.g., "webp", "jpg", "png").
  • guidanceScale (optional): Influences the guidance during the diffusion process.
  • numberOfOutputs (optional): The number of images you want to generate.

Example Input

{
  "model": "dev",
  "prompt": "pepe sitting on a couch watching crypto charts on a big screen tv, bong sitting on coffee table, pepe has green skin and is wearing a white shirt a chain, cargo shorts, and white nike shoes",
  "aspectRatio": "1:1",
  "outputFormat": "webp",
  "guidanceScale": 3.5,
  "loraIntensity": 1,
  "outputQuality": 90,
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "numberOfInferenceSteps": 28,
  "additionalLoraIntensity": 1
}

Output

Upon successful execution, the action typically returns a URL to the generated image. For example:

[
  "https://assets.cognitiveactions.com/invocations/e8b1c046-390c-4a8f-8fdc-bca761ac80d8/e9ec280f-1c54-419a-b583-41dccbaa9ab5.webp"
]

Conceptual Usage Example (Python)

Here’s a conceptual Python code snippet demonstrating how to call this action using a hypothetical Cognitive Actions execution endpoint:

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 = "8e9df220-27a1-4adb-ad93-3b3b2ca2d0b4" # Action ID for Generate Custom Image with Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "pepe sitting on a couch watching crypto charts on a big screen tv, bong sitting on coffee table, pepe has green skin and is wearing a white shirt a chain, cargo shorts, and white nike shoes",
    "aspectRatio": "1:1",
    "outputFormat": "webp",
    "guidanceScale": 3.5,
    "loraIntensity": 1,
    "outputQuality": 90,
    "promptStrength": 0.8,
    "numberOfOutputs": 1,
    "numberOfInferenceSteps": 28,
    "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 snippet:

  • Replace the COGNITIVE_ACTIONS_API_KEY with your actual API key.
  • The action_id corresponds to the "Generate Custom Image with Inpainting" action.
  • The payload is constructed as per the input schema, and you can modify it according to your needs.

Conclusion

The maczzzzzzz/pixolpepe Cognitive Actions provide a powerful toolkit for developers looking to incorporate advanced image generation features into their applications. By leveraging the capabilities of the "Generate Custom Image with Inpainting" action, you can create stunning visuals tailored to your specifications with ease.

Consider exploring additional use cases or integrating more actions to enhance your applications further. Happy coding!