Create Stunning Images with Leafy Cushion's Inpainting Action

26 Apr 2025
Create Stunning Images with Leafy Cushion's Inpainting Action

In the ever-evolving world of digital content creation, having tools that streamline and enhance the creative process is crucial. The "Leafy Cushion" service offers a powerful Cognitive Action specifically designed for image generation: the "Generate Enhanced Inpainting Images." This action allows developers to create visually striking images by filling in gaps or modifying existing images with advanced inpainting techniques. With customizable settings such as prompt strength, LoRA intensity, and guidance scale, you can achieve remarkable results tailored to your needs.

Whether you are looking to enhance product images for e-commerce, create captivating visuals for social media, or simply explore the creative possibilities of image manipulation, the Leafy Cushion's inpainting action provides a flexible and efficient solution. By leveraging this technology, developers can automate image generation processes, saving time and improving the overall quality of visual content.

Prerequisites

To get started with Leafy Cushion's Cognitive Actions, you'll need an API key and a basic understanding of making API calls.

Generate Enhanced Inpainting Images

The "Generate Enhanced Inpainting Images" action is designed to create inpainting images with customizable parameters, allowing developers to refine the output to their specific requirements. This action addresses the need for high-quality image generation, enabling users to modify existing images or create new ones from prompts effectively.

Input Requirements: The action requires a structured input with the following key properties:

  • prompt: A textual description guiding the image generation (e.g., "a photo of a LEAFYCUSHION cushion on a designer sofa in a showroom").
  • mask: (Optional) An image mask to specify areas for inpainting.
  • image: (Optional) An input image to modify.
  • model: Choose between "dev" for optimal performance or "schnell" for faster results.
  • aspectRatio, width, height: Define the dimensions of the generated image.
  • loraScale, promptIntensity, guidanceIntensity: Control the intensity of various effects during image generation.
  • outputCount, outputFormat, outputQuality: Specify the number of outputs and their format and quality.

Expected Output: The action returns a URL to the generated image, which can be accessed and utilized in various applications.

Use Cases for this specific action:

  • E-commerce: Generate high-quality product images that showcase items in an appealing context, enhancing customer engagement.
  • Social Media: Create unique visuals that stand out in crowded feeds, drawing attention and increasing shares.
  • Creative Projects: Experiment with artistic styles and concepts by manipulating existing images or creating new ones based on text prompts.
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 = "97591495-12cf-4fbf-9739-5923428a4e2f" # Action ID for: Generate Enhanced Inpainting Images

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "model": "dev",
  "prompt": "a photo of a LEAFYCUSHION cushion on a designer sofa in a showroom",
  "loraScale": 1,
  "runQuickly": false,
  "aspectRatio": "1:1",
  "outputCount": 1,
  "outputFormat": "webp",
  "outputQuality": 80,
  "imageResolution": "1",
  "promptIntensity": 0.8,
  "guidanceIntensity": 3,
  "inferenceStepCount": 28,
  "additionalLoraIntensity": 1
}

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

In summary, Leafy Cushion's "Generate Enhanced Inpainting Images" action offers developers a robust tool for creating and modifying images with precision and creativity. By leveraging customizable parameters, users can tailor the output to meet specific needs, making it an invaluable resource for enhancing visual content across various platforms.

To explore further, consider integrating this action into your projects to streamline your image generation processes or enhance your creative workflows.