Enhance Your Images Effortlessly with Yap Man's Inpainting Action

25 Apr 2025
Enhance Your Images Effortlessly with Yap Man's Inpainting Action

In the world of digital content creation, having the ability to manipulate and enhance images can significantly elevate the quality of your work. Yap Man provides a powerful Cognitive Action focused on image generation through inpainting. This action allows developers to create stunning visuals with advanced customization options, making it ideal for creative professionals who require high-resolution outputs.

The inpainting action not only streamlines the image enhancement process but also offers precise control over various attributes such as size, aspect ratio, quality, and format. Whether you're looking to fill in missing parts of an image or generate entirely new visuals based on specific prompts, Yap Man's capabilities can simplify and speed up your workflow. Common use cases include creating promotional materials, enhancing social media graphics, or producing artwork for digital platforms.

Prerequisites

To get started with Yap Man's Cognitive Actions, you will need an API key for the Cognitive Actions service and a basic understanding of how to make API calls.

Generate Enhanced Image with Inpainting

This operation generates images through inpainting, allowing for advanced customization and editing. It supports precise control over image attributes such as size, aspect ratio, quality, and format. Users can enhance images using advanced options like LoRA application, prompt strength adjustment, and fast generation for quick results. This action is particularly beneficial for creative professionals aiming for high resolution and quality outputs.

Input Requirements

To utilize this action, you need to provide the following inputs:

  • prompt: A descriptive text that guides the image generation, such as "three people hanging out in the cafe YAP."
  • mask: (Optional) A URI of the image mask for inpainting.
  • image: (Optional) A URI of the input image for modification.
  • model: Select between "dev" or "schnell" model for inference.
  • width and height: Specify custom dimensions if needed.
  • goFast: Enable faster predictions if required.
  • outputQuality: Set the desired quality level for the generated image.
  • numberOfOutputs: Indicate how many images you want to generate.

Expected Output

The output will be a URI link to the generated enhanced image. For example:

https://assets.cognitiveactions.com/invocations/28e5bfba-34b6-4f20-ae4e-9e91a60a9460/9c1a7dca-2933-4acf-8518-787fdb567820.png

Use Cases for this specific action

  • Creative Projects: Artists can use this action to quickly generate artwork based on predefined prompts or modify existing images for a unique touch.
  • Marketing Materials: Marketing teams can create compelling visuals that resonate with their audience, enhancing product presentations or social media campaigns.
  • Content Creation: Bloggers and content creators can generate custom images that align with their brand's aesthetic, saving time and effort in sourcing stock images.

```python
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 = "da1a9daf-6f2b-47da-a5f6-879c02261781" # Action ID for: Generate Enhanced Image with Inpainting

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "schnell",
  "goFast": true,
  "prompt": "three people hanging out in the cafe YAP",
  "loraScale": 1.3,
  "guidanceScale": 3.5,
  "outputQuality": 80,
  "extraLoraScale": 1,
  "promptStrength": 0.8,
  "imageMegapixels": "1",
  "numberOfOutputs": 1,
  "imageAspectRatio": "1:1",
  "imageOutputFormat": "png",
  "numInferenceSteps": 4
}

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("------------------------------------------------")


## Conclusion
Yap Man's inpainting action offers a flexible and powerful solution for enhancing images, making it an invaluable tool for developers and creative professionals alike. With its advanced customization options and ability to generate high-quality outputs quickly, you can streamline your workflow and focus on what matters most: creating stunning visuals. 

As you explore this action, consider how it can be integrated into your projects to elevate your image generation capabilities. Start experimenting today and unlock new creative possibilities!