Effortless Image Generation with Diggeclone's Inpainting Action

25 Apr 2025
Effortless Image Generation with Diggeclone's Inpainting Action

In today's digital landscape, the demand for high-quality images is ever-increasing. Whether you're a game developer, a graphic designer, or a content creator, the ability to generate custom images quickly and efficiently can significantly enhance your workflow. Diggeclone offers a powerful Cognitive Action called "Generate Image with Inpainting" that allows developers to create images from detailed text prompts while offering advanced features such as inpainting capabilities. This action not only streamlines the image creation process but also provides flexibility in aspects like resolution, aspect ratio, and generation speed, making it an essential tool for any developer looking to elevate their creative projects.

Prerequisites

To start using Diggeclone's Cognitive Actions, you'll need an API key and a basic understanding of making API calls.

Generate Image with Inpainting

This action creates stunning images based on user-defined text prompts and allows for inpainting using an image mask. It addresses the challenge of generating unique visuals tailored to specific requirements, making it ideal for applications where originality is key.

Input Requirements: The input for this action is structured as a JSON object that includes the following fields:

  • prompt (required): A detailed text description that guides the image creation.
  • mask (optional): A URI pointing to an image mask for inpainting.
  • image (optional): A URI for an existing image to modify.
  • model: Choose between 'dev' for detailed outputs or 'schnell' for rapid generation.
  • aspectRatio: Select from predefined ratios or opt for a custom setting.
  • outputCount: Specify how many images to generate (1-4).
  • outputFormat: Choose the output format (webp, jpg, png).
  • inferenceSteps: Control the number of denoising steps for image quality.

Expected Output: The action returns a list of image URLs corresponding to the generated images, providing quick access to the visual content created based on the specified input.

Use Cases for this specific action:

  1. Game Development: Quickly generate unique character designs or environment art based on narrative descriptions.
  2. Marketing and Advertising: Create tailored visuals for campaigns by describing concepts that resonate with target audiences.
  3. Content Creation: Produce original images for blogs or social media posts, enhancing engagement with visually appealing content.
  4. Art and Design: Experiment with different styles and concepts without the need for manual drawing or graphic design tools.
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 = "3c4a5f89-abce-434e-aa31-161cba43bc8a" # Action ID for: Generate 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": "dev",
  "prompt": "OK pointing to the upper right corner of the screen with one hand, while the other hand is placed on the head as if TOK just had a sudden realization. TOK’s expression is a mix of regret and urgency—wide eyes and a slightly open mouth. The background is a dramatic gradient with glowing elements like fading clocks and swirling papers, leaving space for impactful text.",
  "megapixels": "1",
  "aspectRatio": "16:9",
  "outputCount": 4,
  "outputFormat": "jpg",
  "guidanceScale": 3,
  "loraIntensity": 1,
  "outputQuality": 80,
  "enableFastMode": false,
  "inferenceSteps": 28,
  "promptStrength": 0.8,
  "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

Diggeclone’s "Generate Image with Inpainting" action simplifies the image creation process, allowing developers to focus on their creative vision without getting bogged down by technical details. With its robust features and flexibility, this action is perfect for a wide range of applications, from game design to marketing. By integrating this Cognitive Action into your projects, you can enhance productivity and produce high-quality visuals that stand out. Start exploring the possibilities with Diggeclone today!