Enhance Your Applications with Image Inpainting Using Advaitchauhan/Paroo Cognitive Actions

24 Apr 2025
Enhance Your Applications with Image Inpainting Using Advaitchauhan/Paroo Cognitive Actions

Integrating advanced image processing capabilities into applications has never been easier with the Advaitchauhan/Paroo Cognitive Actions. This powerful API allows developers to perform sophisticated tasks like image inpainting, enabling them to enhance and manipulate images seamlessly. With pre-built actions, you can save time and effort while providing high-quality visual outputs. In this post, we'll explore the Perform Image Inpainting action, detailing its features, input requirements, output format, and how to integrate it into your applications.

Prerequisites

Before diving into the action specifics, ensure you have the following prerequisites:

  • An API key for the Cognitive Actions platform to authorize your requests.
  • Basic understanding of JSON format for constructing payloads.
  • Familiarity with Python for implementing the provided code examples.

Authenticating with the API typically involves passing your API key in the request headers to ensure secure access to the Cognitive Actions.

Cognitive Actions Overview

Perform Image Inpainting

The Perform Image Inpainting action allows you to creatively alter images by filling in specified areas based on the provided prompt and optional mask. You can choose between two models: 'dev' for detailed processing or 'schnell' for faster results. This action is part of the image processing category.

Input

The input for this action is structured as a JSON object containing several fields. Here’s a breakdown of the required and optional fields based on the input_schema:

  • prompt (required): A textual description guiding the inpainting process.
  • model (optional): Choose between "dev" (default) or "schnell".
  • mask (optional): URI for a mask image to define areas for inpainting.
  • image (optional): URI of the input image.
  • width (optional): Specifies width (in pixels) for the output image.
  • height (optional): Specifies height (in pixels) for the output image.
  • outputCount (optional): Number of output images to generate, default is 1.
  • guidanceScale (optional): Influences the diffusion process, default is 3.
  • outputQuality (optional): Quality of the output image, default is 80.
  • inferenceSteps (optional): Number of denoising steps, default is 28.
  • imageOutputFormat (optional): Format for the output image (e.g., webp, jpg, png).

Here’s an example input JSON payload:

{
  "model": "dev",
  "prompt": "PAROO swimming in a community swimming pool. PAROO face is clearly visible",
  "outputCount": 2,
  "guidanceScale": 3.5,
  "outputQuality": 90,
  "inferenceSteps": 28,
  "imageOutputFormat": "webp"
}

Output

The output of the action is an array of image URLs, each pointing to the generated inpainted image. Here’s an example of what you can expect in the response:

[
  "https://assets.cognitiveactions.com/invocations/ad9c96fd-3eae-42a9-a9a4-05e8e9854b1a/e4336888-dfc4-49d0-9457-60969b5e0dae.webp",
  "https://assets.cognitiveactions.com/invocations/ad9c96fd-3eae-42a9-a9a4-05e8e9854b1a/09aa20f7-ea69-419d-86e1-60d04743b338.webp"
]

The URLs will point to the generated images, which can be displayed or processed further in your application.

Conceptual Usage Example (Python)

Here’s how you would use the Perform Image Inpainting action in a Python script. This example demonstrates how to structure the input payload and make a request to the 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 = "8da25a2a-7613-4f79-8105-45617c131bbb"  # Action ID for Perform Image Inpainting

# Construct the input payload based on the action's requirements
payload = {
    "model": "dev",
    "prompt": "PAROO swimming in a community swimming pool. PAROO face is clearly visible",
    "outputCount": 2,
    "guidanceScale": 3.5,
    "outputQuality": 90,
    "inferenceSteps": 28,
    "imageOutputFormat": "webp"
}

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 placeholder API key with your actual key. The action ID and input payload are structured according to the requirements of the Perform Image Inpainting action.

Conclusion

The Advaitchauhan/Paroo Cognitive Actions, particularly the Perform Image Inpainting action, provide a robust solution for developers looking to enhance their applications with advanced image processing capabilities. By leveraging these pre-built actions, you can focus on building innovative features without worrying about the complexities of image manipulation.

Start experimenting with image inpainting today and unlock new creative possibilities for your applications!