Create Stunning Images with Inpainting Techniques Using Sdxl Bu 3D

25 Apr 2025
Create Stunning Images with Inpainting Techniques Using Sdxl Bu 3D

In the world of digital content creation, the ability to generate high-quality images quickly and efficiently is invaluable. The Sdxl Bu 3D service offers a powerful Cognitive Action called "Generate Inpainted Image," designed to allow developers to create detailed, customized imagery using advanced inpainting techniques. With options to control various aspects of image generation, this action simplifies the process of creating visually appealing content while providing flexibility for personalization.

Imagine a scenario where you need to fill in missing parts of an image or want to enhance a specific element while maintaining the original aesthetics. The Generate Inpainted Image action is perfect for tasks such as creating artwork, generating marketing visuals, or enhancing media content. By leveraging this action, developers can save time and resources while producing high-quality images tailored to their specific needs.

Prerequisites

To get started with the Sdxl Bu 3D Cognitive Actions, you'll need an API key and a foundational understanding of making API calls.

Generate Inpainted Image

The Generate Inpainted Image action allows you to create images using inpainting techniques, enabling you to customize various parameters such as width, height, and refinement style. This action is particularly beneficial for generating detailed imagery with options for watermarks and noise control, making it ideal for diverse creative projects.

Input Requirements

To successfully use this action, you'll need to provide the following inputs:

  • Mask: A URI of the input mask for inpaint mode, indicating which areas to preserve (black) and which to inpaint (white).
  • Image: A URI of the input image for img2img or inpaint mode.
  • Width: The desired width of the output image (default is 1024 pixels).
  • Height: The desired height of the output image (default is 1024 pixels).
  • Prompt: A text prompt guiding the image generation process.
  • Refine Style: The style used for refining the image (options include no_refiner, expert_ensemble_refiner, and base_image_refiner).
  • Guidance Scale: Determines the scale for classifier-free guidance, ranging from 1 to 50.
  • Apply Watermark: Indicates whether to apply a watermark to the generated image.
  • Negative Prompt: A prompt to influence image generation negatively.
  • Prompt Strength: The strength of the initial prompt during img2img or inpaint processes.
  • Number of Outputs: Specifies how many images to generate in a single batch (1 to 4).
  • Scheduling Method: Defines the method used for scheduling steps in the generation process.
  • Additional parameters like high noise fraction, number of inference steps, and LoRA adjustments allow for further customization.

Expected Output

The expected output is a generated image based on the provided parameters, typically returned as a URI link to the image. For example, an output might look like this:

  • https://assets.cognitiveactions.com/invocations/c591c8ad-6865-4329-bd19-a531d43dfbc2/a075f26f-afc6-4fd8-91e3-88c71a890e83.png

Use Cases for this Specific Action

  • Artistic Creation: Artists can use this action to generate unique artwork by refining existing images or creating new compositions based on specific prompts.
  • Marketing Materials: Marketers can quickly create visuals that fit their branding needs by customizing images to suit campaign themes.
  • Media Enhancement: Content creators can enhance images for blogs, social media, or other platforms, ensuring high engagement with visually appealing content.
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 = "9e41f5cb-3a88-42e1-ad29-7dce142fce34" # Action ID for: Generate Inpainted Image

# Construct the exact input payload based on the action's requirements
# This example uses the predefined example_input for this action:
payload = {
  "width": 1024,
  "height": 1024,
  "prompt": "In the style of BetterUp - An office environment with several elements with a vibrant, high contrast color palette with white gray and few highlight of rubine.",
  "refineStyle": "expert_ensemble_refiner",
  "guidanceScale": 7.5,
  "applyWatermark": true,
  "negativePrompt": "",
  "promptStrength": 0.8,
  "numberOfOutputs": 1,
  "schedulingMethod": "K_EULER",
  "highNoiseFraction": 0.8,
  "numInferenceSteps": 50,
  "loraAdjustmentScale": 0.6
}

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

The Sdxl Bu 3D's Generate Inpainted Image action empowers developers to create stunning, customized images efficiently. By leveraging its flexible input options and advanced features, you can enhance your projects with high-quality visuals tailored to your specific requirements. Whether for artistic expression, marketing, or content enhancement, this action opens up a world of possibilities for image generation. Start integrating this powerful tool into your workflow today to elevate your creative projects!